chevgenio / smspilot-notification-channel
SmsPilot 通知渠道用于 Laravel
v1.0.0
2021-03-09 05:42 UTC
Requires
- php: >=7.2
- guzzlehttp/guzzle: ^7.0.1
- illuminate/notifications: ^8.0
- illuminate/queue: ^8.0
- illuminate/support: ^8.0
Requires (Dev)
- mockery/mockery: ^1.3.1
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2024-09-09 15:06:02 UTC
README
此包使您能够使用 Laravel 8.x 简单地通过 smspilot.ru 发送通知。
内容
安装
使用 Composer 安装此包
composer require chevgenio/smspilot-notification-channel
设置 SmsPilot 服务
将您的 SmsPilot API 密钥和默认发送者名称添加到 config/services.php
// config/services.php ... 'smspilot' => [ 'apikey' => env('SMSPILOT_APIKEY'), 'sender' => env('SMSPILOT_SENDER', 'INFORM'), 'callback' => env('SMSPILOT_CALLBACK_URL', ''), 'callback_method' => env('SMSPILOT_CALLBACK_METHOD', 'get'), ], ...
用法
您可以在通知内部的 via()
方法中使用该通道
use Illuminate\Notifications\Notification; use Chevgenio\SmsPilot\SmsPilotMessage; use Chevgenio\SmsPilot\SmsPilotChannel; class NewOrder extends Notification { public function via($notifiable) { return [SmsPilotChannel::class]; } public function toSmsPilot($notifiable) { return (new SmsPilotMessage) ->content("Order successfully completed."); } }
在您的可通知模型中,请确保包含一个 routeNotificationForSmspilot
方法,该方法返回一个电话号码或电话号码数组。
public function routeNotificationForSmspilot() { return $this->phone; }
可用方法
from()
:设置发送者名称。请确保在您的 SmsPilot 控制台中注册发送者名称。
content()
:设置通知消息的内容。
sendAt()
:设置计划通知消息的时间。
变更日志
有关最近更改的更多信息,请参阅变更日志。
测试
$ composer test
许可证
MIT 许可证(MIT)。有关更多信息,请参阅许可证文件。