aldemco / laravel-notification-channel-sms-ru
此包使您能够使用 Laravel 7.0+ ([sms.ru](https://sms.ru) 或 SMSRU) 发送通知变得简单(fomvasss/laravel-notification-channel-sms-ru 分支)
dev-main
2024-01-08 07:29 UTC
Requires
- php: >=7.2.5
- illuminate/notifications: ^7.0|^8.0|^9.0|^10.0
- illuminate/support: ^7.0|^8.0|^9.0|^10.0
- zelenin/smsru: ^4.1|^5.0
Requires (Dev)
- mockery/mockery: ^1.3
- phpunit/phpunit: ^8.0|^9.0
This package is auto-updated.
Last update: 2024-09-08 08:49:37 UTC
README
以下是 Laravel 通知系统的最新文档
https://laravel.net.cn/docs/master/notifications
内容
安装
使用 Composer 安装此包
composer require aldemco/laravel-notification-channel-sms-ru:dev-main
服务提供者将自动加载。或者您可以手动进行此操作
// config/app.php 'providers' => [ ... NotificationChannels\SmsRu\SmsRuServiceProvider::class, ],
设置 SmsRu 服务
将您的 SmsRu apiID、默认发送者名称(或电话号码)添加到您的 config/services.php
// config/services.php ... 'sms_ru' => [ 'api_id' => env('SMSRU_API_ID'), ], ...
使用
您可以在通知内的 via()
方法中使用此通道
use Illuminate\Notifications\Notification; use NotificationChannels\SmsRu\SmsRuMessage; use NotificationChannels\SmsRu\SmsRuChannel; class AccountApproved extends Notification { public function via($notifiable) { return [SmsRuChannel::class]; } public function toSmsru($notifiable) { return (new SmsRuMessage())->content("Hello SMS!!!")->test(true)->translit(false); } }
在您的可通知模型中,确保包含一个 routeNotificationForSmsru()
方法,该方法返回一个电话号码或电话号码数组。
public function routeNotificationForSmsru() { return $this->phone; }
可用方法
from()
:设置发送者的名称或电话号码。
content()
:设置通知消息的内容。
time()
:示例参数 = time() + 7*60*60
- 延迟发送 7 小时。
translit()
:文本转写
test()
:测试短信发送(免费)
from()
:批准的函件发送者
parentId()
:如果您将代码集成到外部系统中,可以指定您的合作伙伴 ID
致谢
许可
MIT 许可证(MIT)。有关更多信息,请参阅 许可文件