Laravel 5.5+
Send SMS notifications in Laravel powered by SMSPortal. Before you can send notifications via SMSPortal, you need to install the neolikotsi/laravel-smsportal
Composer package:
composer require neolikotsi/laravel-smsportal
The package will automatically register itself.
You can publish the migration with:
php artisan vendor:publish --provider="Illuminate\Notifications\SMSPortalServiceProvider"
This is the contents of the published config file:
return [
'client_id' => env('SMS_PORTAL_CLIENT_ID'),
'secret' => env('SMS_PORTAL_SECRET'),
'base_uri' => env('SMS_PORTAL_URL', 'https://rest.smsportal.com/v1/'),
'delivery_enabled' => env('SMS_PORTAL_DELIVERY_ENABLED', true),
];
If a notification supports being sent as an SMS, you should define a toSmsPortal
method on the notification class. This method will receive a $notifiable
entity and should return a Illuminate\Notifications\Messages\SMSPortalMessage
instance:
/**
* Get the SMSPortal / SMS representation of the notification.
*
* @param mixed $notifiable
* @return SMSPortalMessage
*/
public function toSmsPortal($notifiable)
{
return (new SMSPortalMessage)
->content('Your SMS message content');
}
Add the channel smsportal
to the notification delivery channels.
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail', 'smsportal'];
}
The MIT License (MIT). Please see License File for more information.
₿ BTC Wallet: 18YGRct3jRxkRyxsHG5ByLCkUef7MdXNMw