pugofka/ laravel-smsru-notification-channel
SmsRu 通知驱动
1.0.0
2022-07-29 12:55 UTC
Requires
- php: >=8.0
- illuminate/notifications: 9.*
- illuminate/support: 9.*
- zelenin/smsru: ~5
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: 9.*
This package is auto-updated.
Last update: 2024-09-29 06:09:11 UTC
README
此包使得使用Laravel通过sms.ru发送通知变得简单。
内容
安装
您可以通过composer安装此包
composer require pugofka/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)。有关更多信息,请参阅许可文件。