batyukovstudio/laravel-notification-channels-pushsms-ru
最新稳定版本:v12.0.3
Composer 安装命令:
composer require batyukovstudio/laravel-notification-channels-pushsms-ru
包简介
PushSMS notifications channel for Laravel
README 文档
README
This package makes it easy to send notifications using pushsms.ru with Laravel.
Contents
Installation
Install this package with Composer:
composer require batyukovstudio/laravel-notification-channels-pushsms-ru
The service provider gets loaded automatically. Or you can do this manually:
// config/app.php 'providers' => [ ... NotificationChannels\PushSMS\PushSmsServiceProvider::class, ],
Setting up the PushSms service
Add your PushSms token to your .env:
// .env ... PUSHSMS_TOKEN=qwerty123
Usage
You need to replace Notification extend with PushSmsNotification class.
namespace App\Notifications; use NotificationChannels\PushSMS\Notifications\PushSmsNotification; class MyNotification extends PushSmsNotification { use Queueable; // ... }
PushSmsNotification contains $content variable for your text message and toPushSms method. This method will receive a $notifiable entity and should return an NotificationChannels\PushSMS\ApiActions\PushSmsMessage instance:
// PushSmsNotification } use Illuminate\Notifications\Notification; use NotificationChannels\PushSMS\ApiActions\PushSmsMessage; use NotificationChannels\PushSMS\Notifications\Interfaces\PushSmsable; abstract class PushSmsNotification extends Notification implements PushSmsable { protected string $content; public function toPushSms($notifiable): PushSmsMessage { return PushSmsMessage::create()->content($this->content); } }
You can use the channel in your via() method inside the notification:
namespace App\Notifications; use NotificationChannels\PushSMS\Notifications\PushSmsNotification; use NotificationChannels\PushSMS\PushSmsChannel; class MyNotification extends PushSmsNotification { public function via($notifiable) { return [PushSmsChannel::class]; } }
In your notifiable model, make sure to include a routeNotificationForPushsms() method, which returns a phone number
or an array of phone numbers.
public function routeNotificationForPushsms() { return $this->phone; }
Message method
content(): Set a content of the notification message.
统计信息
- 总下载量: 188
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-01