innoflash / za-sms
An SMS package to handle SMS sending from South African providers
Requires
- guzzlehttp/guzzle: ^7.0
- illuminate/events: ^5.1|^6.0|^7.0|^8.0
- illuminate/notifications: ^5.1|^6.0|^7.0|^8.0
- illuminate/queue: ^5.1|^6.0|^7.0|^8.0
- illuminate/support: ^5.1|^6.0|^7.0|^8.0
README
Table of contents
Introduction
This package is aimed at creating a South African SMS package for for local SMS providers using their REST APIs. Below is a list of providers we currently integrated:
Install
composer require innoflash/za-sms
Usage
Once the package is installed you will need to set the provider in the .ENV
file as follows:
ZA_SMS_PROVIDER={provider}
Available providers:
Use as a notification
za-sms supports being a driver for Laravel Notification
- In the
Notifiable
class set your model phone number field by overriding this
function routeNotificationForZasms($notification) { return $this->phone_number; }
- In the
Notification
class use the za-sms as follows
public function via($notifiable) { return [ZaSMSChannel::class]; }
- Then create the notification body as follows
function toZaSMS($notifiable) { return (new ZaSMS) ->message('This is my message') ->sendAt(now()->addDays(2)) // for scheduling messegaes ->campaign('my campain'); //for message campaining }
Use as a Facade
At times you would want to send the SMS your own way so you can use the ZaSMS
facade
ZaSMS::setRecipientNumber('0651562779') ->setMessage('the facade message') ->sendMessage(); //or ZaSMS::setMessageData([ 'recipientNumber' => '0027651562779', 'message' => 'data message' ])->sendMessage();
Additionally
You can also access the SMS Provider object using all available service container methods
$provider = app()->make('za-sms'); $provider = app()->make(SMSProviderContract::class); $provider = resolve('za-sms'); $provider = resolve(SMSProviderContract::class); //or use dependency injection function myFunction(SMSProviderContract $provider){ //todo use the provider }
Contributing
- Please see CONTRIBUTING for details.
- Add a provider using this manual
Security
If you discover any security-related issues, please email innocentmazando@gmail.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.