diviky / laravel-notification-channel-vfirst
短信通知的首选值驱动程序
v1.0.2
2020-09-16 16:27 UTC
Requires
- illuminate/events: ^5|^6|^7|^8
- illuminate/notifications: ^5|^6|^7|^8
- illuminate/support: ^5|^6|^7|^8
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-17 00:51:29 UTC
README
内容
安装
您可以通过composer安装此包
composer require diviky/laravel-notification-channel-vfirst
设置您的账户
将配置添加到您的config/services.php
// config/services.php ... 'vfirst' => [ 'username' => env('VFIRST_USERNAME'), // optional when using auth token 'password' => env('VFIRST_PASSWORD'), // optional when using auth token 'from' => env('VFIRST_FROM'), // optional ], ...
使用
现在您可以在通知内的via()
方法中使用该通道
use NotificationChannels\Vfirst\SmsChannel; use NotificationChannels\Vfirst\Message; use Illuminate\Notifications\Notification; class AccountApproved extends Notification { public function via($notifiable) { return [SmsChannel::class]; } public function toVfirst($notifiable) { return (new Message()) ->text("Your {$notifiable->service} account was approved!"); } }
为了让通知知道您要发送给哪个电话,该通道将查找可通知模型的phone_number
属性和mobile
。如果您想覆盖此行为,将routeNotificationForVfirst
方法添加到您的可通知模型中。
public function routeNotificationForMobtexting() { return '+1234567890'; }
可用的消息方法
from('')
:接受一个电话作为通知发送者。text('')
:接受一个字符串值作为通知正文。to('')
:接受一个字符串值作为通知目标(覆盖默认值)。
贡献
有关详细信息,请参阅CONTRIBUTING。
许可
MIT许可证(MIT)。请参阅许可文件以获取更多信息。