sbudah / panaceamobile
PanaceaMobile 通知驱动程序。
0.0.5
2016-08-24 18:31 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 not auto-updated.
Last update: 2024-09-26 03:49:37 UTC
README
此包简化了使用 Laravel 5.3 和 PanaceaMobile 发送通知的过程。
内容
安装
您可以通过 composer 安装此包。
composer require sbudah/panaceamobile
您必须安装服务提供者。
// config/app.php 'providers' => [ ... NotificationChannels\PanaceaMobile\PanaceaMobileServiceProvider::class, ];
设置 PanaceaMobile 服务
在 Panacea Mobile 上创建一个账户并创建一个 API 令牌。
将您的 PanaceaMobile 登录、密钥(哈希密码)和默认发送者名称添加到您的 config/services.php
// config/services.php 'panaceamobile' => [ 'login' => env('PANACEAMOBILE_LOGIN'), // Your Username 'secret' => env('PANACEAMOBILE_SECRET'), // Your Token 'sender' => 'Sbudah' // Phone number to send SMS from ]
使用
您可以在通知内的 via()
方法中使用该通道
use Illuminate\Notifications\Notification; use NotificationChannels\PanaceaMobile\PanaceaMobileMessage; use NotificationChannels\PanaceaMobile\PanaceaMobileChannel; class AccountApproved extends Notification { public function via($notifiable) { return [PanaceaMobileChannel::class]; } public function toPanaceaMobile($notifiable) { return (new PanaceaMobileMessage()) ->content("Your {$notifiable->service} account was approved!"); } }
为了使通知知道您要发送/拨打电话到哪个手机,通道将查找 Notifiable 模型的 phone_number
属性。如果您想覆盖此行为,请将 routeNotificationForPanaceaMobile
方法添加到您的 Notifiable 模型中。
// app/User.php public function routeNotificationForPanaceaMobile() { return '27111000101'; }
示例 #2
<?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * Route notifications for the Nexmo channel. * * @return string */ public function routeNotificationForPanaceaMobile() { return $this->phone; } }
可用方法
- ->content(''): 指定 SMS 内容/文本。
贡献
有关详细信息,请参阅 CONTRIBUTING。
致谢
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件。