An SMS sender for Laravel 5 with Notification Channel
![Software License][ico-license]
, (*1)
An SMS sender for Laravel 5 with Notification Channel, (*2)
Install
Via Composer, (*3)
$ 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
:, (*4)
KDuma\SMS\SMSServiceProvider::class,
And following facade to facades array:, (*5)
'SMS' => KDuma\SMS\Facades\SMS::class,
Publish sms.php
config file using following command:, (*6)
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., (*7)
Available Drivers
Usage
``` php
SMS::send('phone number', 'Message.');
SMS::balance();
SMS::driver('serwersms')->send('phone number', 'Message.');, (*8)
## Laravel 5.3 Notifications Channel Usage
Follow Laravel's documentation to add the channel your Notification class, for example:
```php
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:, (*9)
public function routeNotificationForSMS()
{
return $this->phone_number;
}
SMSMessage
Available methods
-
content()
- SMS content
-
channel()
- Set the configured SMS channel
Credits
License
The MIT License (MIT). Please see License File for more information., (*10)