This package makes it easy to send notifications using Bonga with Laravel.
This package is part of the Laravel Notification Channels project. It provides additional Laravel Notification channels to the ones given by Laravel itself.
The Bonga channel makes it possible to send out Laravel notifications as a SMS
using Bonga API.
You can install this package via composer:
composer require laravel-notification-channels/bonga
The service provider gets loaded automatically.
You will need to Register and then go to your Developer Hub. On the right, Generate New Key/Secret Pair. Place your API credentias inside your .env
file.
BONGA_CLIENT=""
BONGA_KEY=""
BONGA_SECRET=""
BONGA_SERVICE=""
To load them, add this to your config/services.php
. This will load the Bonga data from the .env
file.file:
'bonga' => [
'client' => env('BONGA_CLIENT'),
'key' => env('BONGA_KEY'),
'secret' => env('BONGA_SECRET'),
'service' => env('BONGA_SERVICE'),
]
Add the routeNotifcationForBonga
method on your notifiable Model. If this is not added,
the phone
field will be automatically used.
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* Route notifications for the Africas Talking channel.
*
* @param \Illuminate\Notifications\Notification $notification
* @return string
*/
public function routeNotificationForBonga($notification)
{
return $this->phone;
}
}
To use this package, you need to create a notification class, like SendOtp
from the example below, in your Laravel application. Make sure to check out Laravel's documentation for this process.
<?php
use NotificationChannels\Bonga\BongaChannel;
use NotificationChannels\Bonga\BongaMessage;
class SendOtp extends Notification
{
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [BongaChannel::class];
}
public function toBonga($notifiable)
{
return (new BongaMessage())
->content('Your SMS message content');
}
}
$ composer test
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.