This package makes it easy to send notifications using Infobip with Laravel 5.4.
With this package you can send SMSs notifications.
You can install the package via composer:
composer require laravel-notification-channels/infobip
You must install the service provider:
// config/app.php
'providers' => [
...
NotificationChannels\Infobip\InfobipServiceProvider::class,
],
To create an Infobip account see Infobip docs
Add your Infobip REST API key to your config/services.php
:
// config/services.php
...
'infobip' => [
'key' => env('INFOBIP_KEY'),
'apiKey' => env('INFOBIP_API_KEY'),
'username' => env('INFOBIP_USERNAME'),
'password' => env('INFOBIP_PASSWORD'),
],
...
On production you only need apiKey
and add key
for reference.
On development setting username
and password
facilitates the API keys management not asking for your credentials
every time.
php artisan infobip:create-api-key name --permissions=ALL
and set publicApiKey
in config/services.php
as apiKey
php artisan list infobip
Now you can use the channel in your via()
method inside the notification:
use NotificationChannels\Infobip\InfobipChannel;
use NotificationChannels\Infobip\InfobipSmsMessage;
use Illuminate\Notifications\Notification;
class InvoiceGenerated extends Notification
{
public function via($notifiable)
{
return [InfobipChannel::class];
}
public function toInfobip($notifiable)
{
return (new InfobipSmsMessage())
->content("Your {$notifiable->last_invoice} was generated!");
}
}
Infobip channel will look for a routeNotificationForInfobip
method on your Notifiable model first then
for the phone_number
or mobil
attribute of the Notifiable model to get the destination number. Remember
to add the country code.
public function routeNotificationForInfobip()
{
return '+1' . $this->mobil;
}
content('')
: Accepts a string value for the notification body.
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email ricardo dot ramirez dot r at gmail dot you know instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.