SMS notification channel for Laravel 5.3
This package makes it easy to send notifications using sms.ru with Laravel 5.3., (*1)
Contents
Installation
You can install this package via composer:, (*2)
``` bash
composer require enniel/laravel-smsru-notification-channel, (*3)
Next add the service provider to your `config/app.php`:
```php
...
'providers' => [
...
NotificationChannels\SmsRu\SmsRuServiceProvider::class,
],
...
Setting up the configuration
Add your API ID (secret key) and default sender name to your config/services.php:, (*4)
// config/services.php
...
'smsru' => [
'api_id' => env('SMSRU_API_ID'),
'sender' => 'John_Doe'
],
...
Usage
Now you can use the channel in your via() method inside the notification:, (*5)
``` php
use NotificationChannels\SmsRu\SmsRuChannel;
use NotificationChannels\SmsRu\SmsRuMessage;
use Illuminate\Notifications\Notification;, (*6)
class ExampleNotification extends Notification
{
public function via($notifiable)
{
return [SmsRuChannel::class];
}, (*7)
public function toSmsRu($notifiable)
{
return SmsRuMessage::create('message text');
}
}, (*8)
In order to let your Notification know which phone number you are targeting, add the `routeNotificationForSmsRu` method to your Notifiable model.
### Available message methods
- `from()`: Sets the sender's name.
- `text()`: Sets a text of the notification message.
## Testing
``` bash
$ composer test
Contributing
Please see CONTRIBUTING for details., (*9)
Credits
License
The MIT License (MIT). Please see License File for more information., (*10)