zanozik / semysms
SemySMS 通知渠道用于 Laravel
v0.1
2017-02-06 04:07 UTC
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ^6.2
- illuminate/notifications: ^5.3
- illuminate/queue: ^5.3
- illuminate/support: ^5.1|^5.2|^5.3
This package is auto-updated.
Last update: 2024-09-08 08:44:34 UTC
README
安装
您可以通过 composer 安装此包
composer require zanozik/semysms
您必须安装服务提供者
// config/app.php 'providers' => [ ... NotificationChannels\SemySMS\SemySMSServiceProvider::class, ],
设置 SemySMS 服务
在 SemySMS 上注册并创建您的令牌 -> 控制面板 -> API。
添加以下部分并填写详细信息(您也可以使用 .env 文件来存储您的凭证)
// config/services.php ... 'semysms' => [ 'token' => env('SEMYSMS_TOKEN', '12345678901234567890'), 'device' => env('SEMYSMS_DEVICE', '12345') ], ...
用法
现在您可以在通知类的 via() 方法中使用此通道
use NotificationChannels\SemySMS\SemySMSChannel; use NotificationChannels\SemySMS\SemySMSMessage; use Illuminate\Notifications\Notification; class InvoicePaid extends Notification{ public function via($notifiable){ return [SemySMSChannel::class]; } public function toSmsGatewayMe($notifiable){ return (new SemySMSMessage)->text('Your invoice has been paid'); } }
路由消息
您应该在您的可通知模型中添加 routeNotificationForSemySMS() 方法
... /** * Route notifications for the SemySMS channel. * * @return int */ public function routeNotificationForSemySMS(){ return $this->phone_number; } ...
可用方法
text($text): (string) 短信文本。
许可证
MIT 许可证(MIT)。有关更多信息,请参阅许可证文件。