PHP code example of laravel-notification-channels / webex
1. Go to this page and download the library: Download laravel-notification-channels/webex library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laravel-notification-channels / webex example snippets
/**
* Get the Webex Message representation of the notification.
*
* @return \NotificationChannels\Webex\WebexMessage
*
* @throws \NotificationChannels\Webex\Exceptions\CouldNotCreateNotification
*/
public function toWebex(mixed $notifiable)
{
return (new WebexMessage)
->text('The message, in plain text.')
->markdown('# The message, in Markdown format.')
->file(function (WebexMessageFile $file) {
$file->path('https://www.webex.com/content/dam/wbx/global/images/webex-favicon.png');
});
}
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use NotificationChannels\Webex\WebexChannel;
class InvoicePaid extends Notification
{
use Queueable;
// ...
/**
* Get the notification's delivery channels.
*/
public function via(mixed $notifiable): array
{
return [WebexChannel::class];
}
// ...
}
public function toWebex(mixed $notifiable): WebexMessage
{
return (new WebexMessage)
->text('Invoice Paid!');
}
public function toWebex(mixed $notifiable): WebexMessage
{
return (new WebexMessage)
->markdown('# Invoice Paid!');
}
public function toWebex(mixed $notifiable): WebexMessage
{
$messageId = "Y2lzY29zcGFyazovL3VybjpURUFNOnVzLXdlc3QtMl9yL01FU1NBR0UvNGY0ZGExOTAtOGUyMy0xMWVjLTljZWQtNmZkZWE5MjMxNmNj"
return (new WebexMessage)
->parentId($messageId)
->text("Invoice Paid!" . "\n"
"No Further action
public function toWebex(mixed $notifiable): WebexMessage
{
$filePath = 'storage/app/invoices/uwnQ0uAXzq.pdf';
return (new WebexMessage)
->file(function (WebexMessageFile $file) use ($filePath){
$file->path($filePath) //
public function toWebex(mixed $notifiable): WebexMessage
{
return (new WebexMessage)
->markdown('We are in the webexteams://im?space=f58064a0-8e21-11ec-9d53-739134f9a8eb space.');
}
public function toWebex(mixed $notifiable): WebexMessage
{
$mentionPersonEmail = '[email protected]';
return (new WebexMessage)
->markdown("Hello <@personEmail:$mentionPersonEmail|Babu Bhaiya>! Your invoice is ready for payment.");
}
public function toWebex(mixed $notifiable): WebexMessage
{
$mentionPersonId = 'Y2lzY29zcGFyazovL3VzL1BFT1BMRS85OTRmYjAyZS04MWI1LTRmNDItYTllYy1iNzE2OGRlOWUzZjY';
return (new WebexMessage)
->markdown("Hello <@personId:$mentionPersonId|Babu Bhaiya>! Your invoice is ready for payment.");
}
public function toWebex(mixed $notifiable): WebexMessage
{
return (new WebexMessage)
->markdown('Hello <@all>! An invoice is ready for payment.');
}
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
/**
* Route notifications for the Webex channel.
*
* @param \Illuminate\Notifications\Notification $notification
* @return string|null
*/
public function routeNotificationForWebex($notification): string|null
{
if (!empty($this->email)) { // a Webex registered email address
return $this->email;
} else if (!empty($this->personId)) { // a Webex HTTP API resource identifier for a user
return $this->personId;
} else if (!empty($this->roomId)) { // a Webex HTTP API resource identifier for a room/space
return $this->roomId;
}
return null; // don't route notification for Webex channel
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.