toonday/laravel-bulksmsnigeria-notification

A laravel channel for bulk nigeria sms provider.

1.0.2 2018-11-21 11:36 UTC

This package is not auto-updated.

Last update: 2024-06-09 03:39:59 UTC


README

Build Status

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:

Methods Usage
body Content of the message
from If not specified in the .env file, this method will set the from parameter. In the case where it has already been set, it'll take precedence and reset the parameter.

With all that in place you can proceed to sending your text messages.

Happy coding.