ossycodes / nigeriabulksms
This package makes it easy to send notifications via Nigeriabulksms with Laravel
Installs: 1 287
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 0
Forks: 1
Open Issues: 0
pkg:composer/ossycodes/nigeriabulksms
Requires
- php: >=7.2.5
 - illuminate/notifications: 5.5 - 10.0
 - illuminate/support: 5.5 - 10.0
 - ossycodes/nigeriabulksms-php: ^1.0
 
Requires (Dev)
- mockery/mockery: ^1.0
 - phpunit/phpunit: ^8.0
 
README
This package makes it easy to send notifications using Nigeriabulksms with Laravel 5 and above
Contents
- About
 - Installation
 - Setting up the Nigeriabulksms service
 - Usage
 - Security
 - Contributing
 - Credits
 - License
 
About
This package makes it possible to send out Laravel notifications as a SMS  using Nigeriabulksms API.
Installation
You can install this package via composer:
composer require ossycodes/nigeriabulksms
The service provider gets loaded automatically.
Setting up the Nigeriabulksms service
You will need to Register to get your username and password. Place them inside your .env file. Remember to add your Sender ID that you will be using to send the messages.
NIGERIABULKSMS_USERNAME="" NIGERIABULKSMS_PASSWORD="" NIGERIABULKSMS_SENDER=""
To load them, add this to your config/services.php . This will load the Nigeriabulksms  data from the .env file.file:
'nigeriabulksms' => [ 'username' => env('NIGERIABULKSMS_USERNAME'), 'password' => env('NIGERIABULKSMS_PASSWORD'), 'sender' => env('NIGERIABULKSMS_SENDER'), ]
Add the routeNotifcationForNigeriabulksms method on your notifiable Model.
<?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * Route notifications for the Nigeriabulksms channel. * * @param \Illuminate\Notifications\Notification $notification * @return string */ public function routeNotificationForNigeriabulksms($notification) { return $this->phone; } }
Usage
To use this package, you need to create a notification class, like NewsWasPublished from the example below, in your Laravel application. Make sure to check out Laravel's documentation for this process.
<?php use NotificationChannels\Nigeriabulksms\NigeriabulksmsChannel; use NotificationChannels\Nigeriabulksms\NigeriabulksmsMessage; class NewsWasPublished extends Notification { /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [NigeriabulksmsChannel::class]; } public function toNigeriabulksms($notifiable) { return (new NigeriabulksmsMessage()) ->setContent('Your SMS message content'); } }
Additionally you can add recipients(the phonenumber the messages will be sent to) (single value or array)
return (new NigeriabulksmsMessage("Your {$notifiable->service} was ordered!"))->setRecipients($recipients);
also you can add who the notification(sms) is sent from, this will overide the NIGERIABULKSMS_SENDER="" in your .env
return (new NigeriabulksmsMessage("Your {$notifiable->service} was ordered!"))->setFrom("name of your app");
Incase of errors from Nigeriabulksms service please do well to check Nigeriabulksms api error codes on thier developer portal
Security
If you discover any security-related issues, please email osaigbovoemmanuel1@gmail.com instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
How do I say Thank you?
Leave a star and follow me on Twitter .