PHP code example of laravel-notification-channels / smsapi
1. Go to this page and download the library: Download laravel-notification-channels/smsapi 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 / smsapi example snippets
use Illuminate\Notifications\Notification;
use NotificationChannels\Smsapi\SmsapiChannel;
use NotificationChannels\Smsapi\SmsapiSmsMessage;
class FlightFound extends Notification
{
public function via($notifiable)
{
return [SmsapiChannel::class];
}
public function toSmsapi($notifiable)
{
return (new SmsapiSmsMessage())->content("Buy now your flight!");
}
}
use Illuminate\Notifications\Notification;
use NotificationChannels\Smsapi\SmsapiChannel;
use NotificationChannels\Smsapi\SmsapiMmsMessage;
class AnimalTrespassed extends Notification
{
public $photoId;
public function via($notifiable)
{
return [SmsapiChannel::class];
}
public function toSmsapi($notifiable)
{
return (new SmsapiMmsMessage())->subject('Animal!')->smil($this->smil());
}
private function smil()
{
$url = route('photos', ['id' => $this->photoId]);
$smil =
"<smil>" .
"<head>" .
"<layout>" .
"<root-layout height='100%' width='100%'/>" .
"<region id='Image' width='100%' height='100%' left='0' top='0'/>" .
"</layout>" .
"</head>" .
"<body><par><img src='{$url}' region='Image' /></par></body>" .
"</smil>";
return $smil;
}
}
public function routeNotificationForSmsapi()
{
return $this->phone_number;
}
public function routeNotificationForSmsapiGroup()
{
return $this->contacts_group;
}