enniel / laravel-epochta-notification-channel
Epochta 通知驱动
v0.0.1
2016-10-20 12:45 UTC
Requires
- php: >=5.5.9
- enniel/epochta: ~0.0.1
- illuminate/notifications: ~5.1
- illuminate/support: ~5.1
- psr/http-message: ~1.0.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ~1.12.2
This package is auto-updated.
Last update: 2024-09-06 03:46:42 UTC
README
此包使用 Laravel 5.3,通过 Epochta 即 Atompark 发送通知变得简单。
内容
安装
您可以通过 composer 安装此包
composer require enniel/laravel-epochta-notification-channel
接下来,将服务提供者添加到您的 config/app.php
... 'providers' => [ ... NotificationChannels\Epochta\EpochtaServiceProvider::class, ], ...
配置设置
将您的私钥和公钥添加到您的 config/services.php
// config/services.php ... 'epochta' => [ 'sms' => [ 'public_key' => env('EPOCHTA_SMS_PUBLIC_KEY'), 'private_key' => env('EPOCHTA_SMS_PRIVATE_KEY'), ], ], ...
使用方法
现在您可以在通知中的 via()
方法中使用该通道
use NotificationChannels\Epochta\EpochtaChannel; use NotificationChannels\Epochta\EpochtaMessage; use Illuminate\Notifications\Notification; class ExampleNotification extends Notification { public function via($notifiable) { return [EpochtaChannel::class]; } public function toEpochta($notifiable) { return (new EpochtaMessage()) ->text('message text') ->sender('test'); } }
为了让通知知道您要针对哪个电话号码,将 routeNotificationForEpochta
方法添加到您的 Notifiable 模型中。
可用的消息方法
from()
: 发送者的身份。text()
: 消息文本。to()
: 收件人的电话号码。at()
: 在指定时间发送消息。life()
: 生命周期短信(0 = 最大,1, 6, 12, 24小时)。type()
: 对于俄罗斯,可以指定分发类型参数的类型。
测试
$ composer test
致谢
许可
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。