hebinet/laravel-websms-notification-channel

为laravel提供的WebSMS通知通道。

v1.4.0 2023-08-06 08:12 UTC

This package is auto-updated.

Last update: 2024-09-06 10:40:30 UTC


README

提供WebSms通知通道

安装

您可以使用Composer来安装它

composer require hebinet/laravel-websms-notification-channel

然后发布包的配置文件。

php artisan vendor:publish --provider="Hebinet\Notifications\WebSmsChannelServiceProvider" --tag=config

用法

如果一个通知支持以短信的形式发送,您应该在通知类上定义一个toWebsms方法。此方法将接收一个$notifiable实体,并应返回一个包含短信内容的string

/**
 * Get the WebSMS / SMS representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return string
 */
public function toWebsms($notifiable)
{
    return 'Your SMS message content';
}

路由短信通知

要将Nexmo通知路由到正确的电话号码,请在您的可通知实体上定义一个routeNotificationForWebsms方法

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * Route notifications for the WebSms channel.
     *
     * @param  \Illuminate\Notifications\Notification  $notification
     * @return string
     */
    public function routeNotificationForWebsms($notification)
    {
        return $this->phone_number;
    }
}

贡献

请参阅贡献指南以获取详细信息。

安全

如果您发现任何与安全相关的问题,请通过电子邮件office@hebinet.at联系,而不是使用问题跟踪器。

许可证

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