stepovenko/laravel-notification-channel-turbosms

为 Laravel 5.3+ 提供的 Turbo SMS 通知通道。

v1.3 2020-05-19 12:52 UTC

This package is not auto-updated.

Last update: 2024-09-21 07:14:43 UTC


README

基于 github.com/laravel-notification-channels/smsc-ru

此包是为使用 Laravel 5, 6, 7 通过 turbosms.ua 发送通知而制作的。

内容

安装

您可以通过 composer 安装此包:composer require yakimka/laravel-notification-channel-turbosms

对于 Laravel < 5.5,您必须安装服务提供者

// config/app.php
'providers' => [
    ...
    NotificationChannels\TurboSms\TurboSmsServiceProvider::class,
],

设置 TurboSms 服务

将您的 TurboSms 登录、密钥(哈希密码)和默认发送者名称(或电话号码)添加到您的 config/services.php

// config/services.php
...
'turbosms' => [
    'login' => env('TURBOSMS_LOGIN'),
    'secret' => env('TURBOSMS_SECRET'),
    'sender' => 'John Doe',
    'url' => 'http://turbosms.in.ua/api/wsdl.html',
],
...

使用

您可以在通知中的 via() 方法中使用该通道

use Illuminate\Notifications\Notification;
use NotificationChannels\TurboSms\TurboSmsMessage;
use NotificationChannels\TurboSms\TurboSmsChannel;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [TurboSmsChannel::class];
    }

    public function toTurboSms($notifiable)
    {
        return TurboSmsMessage::create("Task #{$notifiable->id} is complete!");
    }
}

在您的可通知模型中,确保包含一个返回电话号码的 routeNotificationForTurboSms() 方法。

public function routeNotificationForTurboSms()
{
    return $this->phone;
}

可用方法

from():设置发送者的名称或电话号码。

content():设置通知消息的内容。

安全

如果您发现任何安全相关的问题,请通过电子邮件 ss.yakim@gmail.com 而不是使用问题跟踪器。

贡献

有关详细信息,请参阅 CONTRIBUTING

鸣谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件