overseegroup / panacea
Laravel 5.6+ 移动通知驱动程序
dev-master
2018-09-14 12:14 UTC
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ~6.0
- illuminate/notifications: ^5.3@dev
- illuminate/queue: ^5.3@dev
- illuminate/support: ^5.3@dev
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4
This package is auto-updated.
Last update: 2024-09-15 01:20:08 UTC
README
本软件包简化了使用 PanaceaMobile 通过 Laravel 5.6+ 发送通知的过程。
安装
您可以通过 composer 安装此软件包
composer require overseegroup/panacea
请确保在您的 config.app 文件中包含了 Service Provider
// config/app.php 'providers' => [ ... NotificationChannels\Panacea\PanaceaServiceProvider::class, ];
配置
此软件包假定您已经在 Panacea Mobile 上拥有一个活跃且可用的账户,并有权访问您的 API 令牌。
一旦您拥有这些详细信息,请将其添加到您的 config/services.php
文件中
// config/services.php 'panacea' => [ 'login' => env('PANACEA_LOGIN'), // Your Username 'api' => env('PANACEA_API'), // Your API Token 'url' => env('PANACEA_URL'), // Your API URL - default: bli.panaceamobile.com/json 'sender' => '0000000000' // Default Sending Number ]
实现
您可以在通知内的 via()
方法中使用该通道
use Illuminate\Notifications\Notification; use NotificationChannels\Panacea\PanaceaMessage; use NotificationChannels\Panacea\PanaceaChannel; class SendSMS extends Notification { public function via($notifiable) { return [PanaceaChannel::class]; } public function toPanacea($notifiable) { return (new PanaceaMessage()) ->content("A test message from Laravel."); } }
可通知配置
为了使本软件包知道发送消息的号码,它将查找可通知模型中的 mobile_number
属性。请将以下代码添加到您的可通知模型中
use Notifiable; /** * Route notifications for the Nexmo channel. * * @return string */ public function routeNotificationForPanacea() { return $this->mobile_number; // or whatever database field you are storing the number field under // or you can hard code the number: // return '27000000000'; } ```