toonday / laravel-bulksmsnigeria-notification
A laravel channel for bulk nigeria sms provider.
Requires
- php: ^5.4.0|^7.0
- guzzlehttp/guzzle: 5.*|6.*
- illuminate/notifications: 5.*
Requires (Dev)
- orchestra/testbench: ~3.0
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2024-10-13 05:34:14 UTC
README
This is a laravel package for sending sms (or bulk sms) to local (Nigerian) phone numbers for Laravel >=5.3.*.
Installation is pretty straight forward: use either
composer require toonday/laravel-bulksmsnigeria-notification
or add to your composer.json
file:
{ "require": { "toonday/laravel-bulksmsnigeria-notification": "~1.0" } }
if using laravel <=5.3.*, add the provider to your app.php
file like so:
"providers" => [ ... "Toonday\BulkSMSNigeria\BulkSMSNigeriaServiceProvider", ... ]
Please do not forget to publish the config file with the artisan
command like so:
php artisan vendor:publish --provider="Toonday\BulkSMSNigeria\BulkSMSNigeriaServiceProvider" --tag=config
and you're all good to go.
If you haven't, please proceed to the bulksmsnigeria to register and get your api token
. Then include in your .env
file the following:
BULKSMSNIGERIA_FROM=token
The package works just like your typical laravel built in notification package. Just add the notifiable trait to the model using the notification (typically the User model) as highlighted here. Further, you should add this method to the same model so the package can know which property of the model to target:
public function routeNotificationForBulkSMSNigeria($notification) { return $user->phone_number; }
In your notification class, add the following lines:
... use Toonday\BulkSMSNigeria\BulkSMSNigeriaChannel; ... public function via($notifiable) { return [BulkSMSNigeriaChannel::class]; }
To compose your message, you can follow the example below:
... use Toonday\BulkSMSNigeria\BulkSMSMessage; ... public function toBulkSmsNigeria($notifiable) { return (new BulkSMSMessage) ->body('This a test message'); }
The BulkSMSMessage class provides the following methods for you:
With all that in place you can proceed to sending your text messages.
Happy coding.