keital/laravel-mobizon

Mobizon SMS 通知驱动程序用于 Laravel

dev-master 2022-09-10 20:45 UTC

This package is auto-updated.

Last update: 2024-09-11 01:31:20 UTC


README

安装

通过 composer 安装

composer require Alitvinov/LaravelMobizon

设置您的 Mobizon 服务

将您的 Mobizon 凭据添加到 config/services.php – 这是一个存储第三方服务凭据的常见文件。

// config/services.php
...
'mobizon' => [
    'domain' => '', 
    'secret' => '',
    'alphaname' => null,
],

用法

该软件包提供了一个新的通道,可以在您的通知类中像以下这样使用

use Illuminate\Notifications\Notification;
use Alitvinov\LaravelMobizon\MobizonChannel;
use Alitvinov\LaravelMobizon\MobizonMessage;

public function via($notifiable)
{
    return [MobizonChannel::class];
}

public function toMobizon($notifiable)
{
    return MobizonMessage::create("Your SMS message");
}

在您的可通知模型中添加一个 routeNotificationForMobizon 方法来返回电话号码

public function routeNotificationForMobizon()
{
    //Phone number without symbols or spaces
    return $this->phone_number;
}

鸣谢

感谢 lararakeiai 提供原始软件包。

许可

MIT 许可证 (MIT)。请参阅 许可文件 获取更多信息。