Jusibe SMS Channel for Laravel 5.3

1.1.0 2020-04-26 01:32 UTC

This package is auto-updated.

Last update: 2024-08-26 11:00:13 UTC


README

Latest Version on Packagist Software License StyleCI Build Status Quality Score Code Coverage Total Downloads

此包简化了使用 Laravel 5.5+、6.x 和 7.x 发送 Jusibe 通知的过程。

内容

安装

您可以通过 composer 安装此包。

composer require laravel-notification-channels/jusibe

您必须安装服务提供者。

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

设置您的 Jusibe 账户

将您的 Jusibe 账户密钥、访问令牌和发送者号码(可选)添加到您的 config/services.php 文件中。

// config/services.php
...
'jusibe' => [
    'key' => env('JUSIBE_PUBLIC_KEY'),
    'token' => env('JUSIBE_ACCESS_TOKEN'),
    'sms_from' => 'PROSPER'
],
...

使用

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

use NotificationChannels\Jusibe\JusibeChannel;
use NotificationChannels\Jusibe\JusibeMessage;
use Illuminate\Notifications\Notification;

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

    public function toJusibe($notifiable)
    {
        return (new JusibeMessage())
            ->content("Your {$notifiable->service} account was approved!");
    }
}

为了让您的通知知道您要发送给哪个电话号码,将 routeNotificationForJusibe 方法添加到您的 Notifiable 模型中,例如您的用户模型。

public function routeNotificationForJusibe()
{
    return $this->phone; // where `phone` is a field in your users table;
}

可用的消息方法

JusibeMessage

  • from(''):接受一个用于通知发送者的电话号码。
  • content(''):接受一个字符串值作为通知正文。

变更日志

请参阅 CHANGELOG 获取更多信息。

测试

$ composer test

安全

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

贡献

有关详细信息,请参阅 CONTRIBUTING

致谢

许可协议

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