undjike/lmt-laravel-notification-channel

基于LMT短信服务的Laravel通知通道

v1.0.1 2024-08-22 06:58 UTC

This package is auto-updated.

Last update: 2024-09-22 07:11:13 UTC


README

logo

Latest Stable Version License Total Downloads Dependents

简介

这是一个用于Laravel应用程序的包,允许您通过LMT短信通道发送通知。

此包使用 LMT API服务 来执行短信发送。

安装

此包可以通过composer安装。只需键入

composer require undjike/lmt-laravel-notification-channel

用法

安装后,您可以在 config/services.php 中配置您的服务,添加

<?php

return [
    //...

    'lmt' => [
        'key' => env('LMT_API_KEY'), // Your credentials are expected here
        'secret' => env('LMT_API_SECRET')
    ],
];

完成此操作后,您就可以像往常一样创建通知。

<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use Undjike\LmtNotificationChannel\LmtChannel;
use Undjike\LmtNotificationChannel\LmtMessage;

class LmtNotification extends Notification
{
    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [LmtChannel::class]; // or return 'lmt';
    }

    /**
     * @param $notifiable
     * @return mixed
     */
    public function toLmt($notifiable)
    {
        return LmtMessage::create()
            ->body('Type here you message content...')
            ->sender('Brand name');
        // or return 'Type here you message content...';
    }
}

要完全启用这些功能,您需要在可通知模型中添加以下内容。

    /**
     * Attribute to use when addressing LMT SMS notification
     *
     * @returns string|array
     */
    public function routeNotificationForLmt()
    {
        return $this->phone_number; // Can be a string or an array of valid phone numbers
    }

享受吧!

许可证

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