websms/laravel-notification
最新稳定版本:1.0.0
Composer 安装命令:
composer require websms/laravel-notification
包简介
WebSms Laravel Notification
README 文档
README
WebSms Laravel Notification
Installation
You can install the package via composer:
$ composer require websms/laravel-notification
You must install the service provider:
// config/app.php 'providers' => [ ... Websms\LaravelNotification\WebSmsServiceProvider::class, ]
Setting up your WebSms account
Add your WebSms Username, Password and Sender Number to your config/services.php:
// config/services.php ... 'websms' => [ 'username' => env('WEBSMS_USERNAME'), 'password' => env('WEBSMS_PASSWORD'), 'sendNumber' => env('WEBSMS_SENDNUMBER'), ], ...
// .env WEBSMS_USERNAME=your_username WEBSMS_PASSWORD=your_password WEBSMS_SENDNUMBER=send_number
Usage
Now you can use the channel in your via() method inside the notification:
/** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [WebSmsChannel::class]; } /** * Get the sms representation of the notification. * * @param mixed $notifiable * @return string */ public function toSms($notifiable) { $webSmsMessage = new WebSmsMessage(); $webSmsMessage->setFrom(env('WEBSMS_SENDNUMBER')); $webSmsMessage->setTo($notifiable->routeNotificationFor('sms')); $webSmsMessage->setMessage($this->message); return $webSmsMessage; }
In order to let your Notification know which phone number you are sending to, add the routeNotificationForSms method to your Notifiable model e.g your User Model
public function routeNotificationForSms() { return $this->phone; // where `phone` is a field in your users table; }
Conterbuter
- Mohammad Hosseini webp1995@gmail.com
统计信息
- 总下载量: 15.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-09-28