程序员777/laravel_mobizon

Laravel的Mobizon通知渠道

0.1.2 2018-04-29 13:56 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:56:30 UTC


README

此包简化了使用mobizon.kz通过Laravel发送通知的过程。

安装

您可以通过composer安装此包

composer require aizhar777/laravel_mobizon

发布配置

php artisan vendor:publish --provider="Aizhar777\Mobizon\MobizonServiceProvider"

然后您必须安装服务提供者

// config/app.php
'providers' => [
    ...
    Aizhar777\Mobizon\MobizonServiceProvider::class,
],

在配置中安装您的API密钥

// config/mobizon.php
return [
    'alphaname' => null,
    'secret' => 'Your secret API key',
];

用法

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

use Illuminate\Notifications\Notification;
use Aizhar777\Mobizon\MobizonMessage;
use Aizhar777\Mobizon\MobizonChanel;

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

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

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

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