enniel / laravel-asterisk-notification-channel
Asterisk 通知驱动
0.1.1
2017-02-03 05:52 UTC
Requires
- php: >=5.6.4
- enniel/ami: ~2.1.0
- illuminate/notifications: ~5.3
- illuminate/support: ~5.1
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-06 03:43:54 UTC
README
本包通过使用 Asterisk 管理器接口 (AMI) 和 Asterisk Chan Dongle,使得在 Laravel 5.3 中发送通知变得简单。
内容
安装
您可以通过 composer 安装此包
composer require enniel/laravel-asterisk-notification-channel
然后,将服务提供者添加到您的 config/app.php
... 'providers' => [ ... NotificationChannels\Asterisk\AsteriskServiceProvider::class, ], ...
配置 Asterisk 服务
使用
现在您可以在通知内部的 via()
方法中使用此通道
use NotificationChannels\Asterisk\AsteriskChannel; use NotificationChannels\Asterisk\AsteriskMessage; use Illuminate\Notifications\Notification; class ExampleNotification extends Notification { public function via($notifiable) { return [AsteriskChannel::class]; } public function toAsterisk($notifiable) { return AsteriskMessage::create('message text'); } }
为了让您的通知知道您针对哪个电话号码,将 routeNotificationForAsterisk
方法添加到您的 Notifiable 模型中。
重要提示:Asterisk 需要收件人的电话号码以国际格式提供。例如:0031612345678
public function routeNotificationForAsterisk() { return '0031612345678'; }
可用的消息方法
content('test')
:设置消息文本。device('modem1')
:设置发送短信消息的设备。
测试
$ composer test
贡献
有关详细信息,请参阅 CONTRIBUTING
致谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 获取更多信息。