enniel / laravel-smsru-notification-channel
SmsRu 通知驱动程序
0.0.1
2016-10-03 11:57 UTC
Requires
- php: >=5.6.4
- illuminate/notifications: ^5.3
- illuminate/support: ^5.1|^5.2|^5.3
- zelenin/smsru: ~4.1.0
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-06 03:26:32 UTC
README
本包可简化使用 Laravel 5.3 通过 sms.ru 发送通知的过程。
内容
安装
您可以通过 composer 安装此包。
composer require enniel/laravel-smsru-notification-channel
接下来,将服务提供者添加到您的 config/app.php
文件中。
... 'providers' => [ ... NotificationChannels\SmsRu\SmsRuServiceProvider::class, ], ...
配置设置
将您的 API ID(密钥)和默认发送者名称添加到 config/services.php
文件中。
// config/services.php ... 'smsru' => [ 'api_id' => env('SMSRU_API_ID'), 'sender' => 'John_Doe' ], ...
用法
现在您可以在通知的 via()
方法中使用此通道。
use NotificationChannels\SmsRu\SmsRuChannel; use NotificationChannels\SmsRu\SmsRuMessage; use Illuminate\Notifications\Notification; class ExampleNotification extends Notification { public function via($notifiable) { return [SmsRuChannel::class]; } public function toSmsRu($notifiable) { return SmsRuMessage::create('message text'); } }
为了使通知知道您要针对哪个电话号码,将 routeNotificationForSmsRu
方法添加到您的可通知模型中。
可用的消息方法
from()
: 设置发送者的名称。text()
: 设置通知消息的文本。
测试
$ composer test
贡献
有关详细信息,请参阅 CONTRIBUTING。
鸣谢
许可
MIT 许可协议(MIT)。有关更多信息,请参阅 许可文件。