This package makes it easy to send notifications using Genusis SMS Gateway via Gensuite API with Laravel.
Install package via Composer:
composer require sykez/genusis-sms
Add the service configration into your config/services.php
:
'genusis-sms' => [
'client_id' => env('GENUSIS_SMS_CLIENT_ID', null),
'username' => env('GENUSIS_SMS_USERNAME', null),
'private_key' => env('GENUSIS_SMS_PRIVATE_KEY', null),
'url' => env('GENUSIS_SMS_URL', null),
'debug_log' => env('GENUSIS_SMS_DEBUG_LOG', false),
],
Add the environment variablesinto your .env
and set your Client ID, Username, Private Key and API URL.
GENUSIS_SMS_CLIENT_ID=
GENUSIS_SMS_USERNAME=
GENUSIS_SMS_PRIVATE_KEY=
GENUSIS_SMS_URL=
Now you can send SMS from your notification:
use Sykez\GenusisSms\GenusisSmsChannel;
use Sykez\GenusisSms\GenusisSmsMessage;
use Illuminate\Notifications\Notification;
class SendSms extends Notification
{
public function via($notifiable)
{
return [GenusisSmsChannel::class];
}
public function toSms($notifiable)
{
return (new GenusisSmsMessage)->content("Hello there!");
}
}
You can route the notification to a phone number with to()
:
public function toSms($notifiable)
{
return (new GenusisSmsMessage)->content("Hello there!")->to(01234567891);
}
Or you can add routeNotificationForSms()
method in your notifiable model:
public function routeNotificationForSms()
{
return $this->phone_number;
}
You can also do on-demand notifications:
use Illuminate\Support\Facades\Notification;
Notification::route('sms', '01234567891')->notify(new App\Notifications\SendSms(['Hello again.']));
You can set your GENUSIS_SMS_DEBUG_LOG=true
in your .env
to send all requests and responses to into your Laravel logs.
The MIT License (MIT). Please see License File for more information.