An SMS sender for Laravel 5 with Notification Channel
Via Composer
$ composer require kduma/sms
In Laravel 5.6, service provider is automatically discovered. If you don't use package discovery,
add the Service Provider to the providers array in config/app.php
:
KDuma\SMS\SMSServiceProvider::class,
And following facade to facades array:
'SMS' => KDuma\SMS\Facades\SMS::class,
Publish sms.php
config file using following command:
php artisan vendor:publish --provider="KDuma\SMS\SMSServiceProvider"
Now You can install and configure SMS channels and drivers. Configuration options are available in drivers readme's.
- SerwerSMS.pl - kduma/sms-driver-serwersms
- JustSend.pl - kduma/sms-driver-justsend
SMS::send('phone number', 'Message.');
SMS::balance();
SMS::driver('serwersms')->send('phone number', 'Message.');
Follow Laravel's documentation to add the channel your Notification class, for example:
use Illuminate\Notifications\Notification;
use KDuma\SMS\NotificationChannel\SMSChannel;
use KDuma\SMS\NotificationChannel\SMSMessage;
class NotificationSMSChannelTestNotification extends Notification
{
public function via($notifiable)
{
return [SMSChannel::class];
}
public function toSMS($notifiable)
{
return SMSMessage::create('This is a test SMS sent via Simple SMS using Laravel Notifications!');
}
}
Also you need to add a routeNotificationForSMS
method to your Notifiable model to return the phone number, for example:
public function routeNotificationForSMS()
{
return $this->phone_number;
}
content()
- SMS contentchannel()
- Set the configured SMS channel
The MIT License (MIT). Please see License File for more information.