avlima / laravel-sms-mmcenter
Laravel 的 MMCenter 短信通知服务
Requires
- php: >=7.1
- guzzlehttp/guzzle: ^6.3
- illuminate/http: >=5.3
- illuminate/notifications: >=5.3
- illuminate/queue: >=5.3
- illuminate/support: >=5.3
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: >=6.5
This package is auto-updated.
Last update: 2024-09-21 20:13:00 UTC
README
集成 Laravel 的 SMS MMCenter
MMCenter SMS 通知服务用于 Laravel。
星标 ⭐ 仓库以示支持 😊
安装
安装包
使用 composer 需要此包
composer require avlima/laravel-sms-mmcenter
添加服务提供者 & Facade
对于 Laravel 5.5+
添加包后,服务提供者和 facade 将自动发现。
对于旧版本的 Laravel
将 ServiceProvider 添加到 config/app.php
中的 providers 数组
Avlima\SmsMMCenter\Providers\SmsMMCenterServiceProvider::class,
将 Facade 添加到 config/app.php
中的 aliases 数组
'SmsMMCenter': Avlima\SmsMMCenter\Facades\SmsMMCenterFacade::class,
发布配置
完成后,使用以下命令将配置发布到您的配置文件夹
php artisan vendor:publish --provider="Avlima\SmsMMCenter\Providers\SmsMMCenterServiceProvider"
配置
在 .env
中添加密钥
MMCENTER_USER=
MMCENTER_PASSWORD=
MMCENTER_TIMEOUT=60
MMCENTER_URL=http://www.mmcenter.com.br/mmenvio.aspx,
MMCENTER_OPERATION=ENVIO
MMCENTER_ROUTE=
配置文件发布后,打开 config/sms-mmcenter.php
使用方法
使用 SmsMMCenter facade
- 基本用法
SmsMMCenter::sendMessage("TO","MESSAGE");
在通知中使用
设置通知路由
将方法 routeNotificationForSmsMMCenter()
添加到您的 Notifiable 模型
public function routeNotificationForSmsMMCenter() {
return $this->phone; //Name of the field to be used as mobile
}
默认情况下,您的 User 模型使用 Notifiable。
设置通知
添加
use Avlima\SmsMMCenter\Notifications\SmsMMCenterChannel;
和
use Avlima\SmsMMCenter\Notifications\SmsMMCenterMessage;
到您的通知。
您可以使用 php artisan make:notification NOTIFICATION_NAME
创建一个新的通知
在您的通知中的 via
函数内,添加 return [SmsMMCenterChannel::class];
并添加一个新函数 toSmsMMCenter($notifiable)
返回消息体和参数。
通知示例:
namespace App\Notifications;
use Avlima\SmsMMCenter\Notifications\SmsMMCenterChannel;
use Avlima\SmsMMCenter\Notifications\SmsMMCenterMessage;
use Illuminate\Notifications\Notification;
class ExampleNotification extends Notification
{
public function via($notifiable)
{
return [SmsMMCenterChannel::class];
}
public function toSmsMMCenter($notifiable)
{
return (new SmsMMCenterMessage)
->to("44999999999")
->content("Hello");
}
}
支持
请随意在问题部分发布您的问题。
致谢
由 Alberto Lima 开发
许可证
MIT