gdpa/kavenegar 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gdpa/kavenegar

Composer 安装命令:

composer require gdpa/kavenegar

包简介

Kavenegar Notifications driver

README 文档

README

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

This package makes it easy to sent Kavenegar Notifications with Laravel 5.3+.

Contents

Installation

You can install the package via composer:

composer require gdpa/kavenegar

Install for laravel 7:

composer require gdpa/kavenegar:^3.4

Install for laravel 6:

composer require gdpa/kavenegar:^2.0

Install for laravel < 5.8:

composer require gdpa/kavenegar:^1.0

Setting up the Kavenegar service

Add your Kavenegar REST API Key to your config/services.php:

// config/services.php
...
'kavenegar' => [
    'api_key' => env('KAVENEGAR_API_KEY'), 
],
...

Usage

There are two channels that you can use in your via() method inside the notification: KavenegarChannel which represent simple send api and KavenegarVerifyChannel which provide verify lookup api.

use NotificationChannels\Kavenegar\KavenegarChannel;
use NotificationChannels\Kavenegar\KavenegarMessage;
use Illuminate\Notifications\Notification;

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

    public function toKavenegar($notifiable)
    {
        return KavenegarMessage::create()
            ->sender("your-desired-sender-number")
            ->message('Hello world');
    }
}
use NotificationChannels\Kavenegar\KavenegarVerifyChannel;
use NotificationChannels\Kavenegar\KavenegarMessage;
use Illuminate\Notifications\Notification;

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

    public function toKavenegar($notifiable)
    {
        return KavenegarMessage::create()
            ->template("your-template-key(Refer to Kavenegar Docs)")
            ->type('sms')
            ->token('your default token on your verify message template')
            ->token('additional token data. For example token10', 10);
    }
}

In order to let your Notification know which Kavenegar user you are targeting, add the routeNotificationForKavenegar method to your Notifiable model.

This method needs to return an array containing the mobile number of your receptor.

public function routeNotificationForKavenegar()
{
    return [
        'mobile_number' => 'receptor mobile number',
    ];
}

Available methods

  • sender(''): Accepts a string value for setting sender number on kavenegar.
  • message(): Accepts a string value for setting your sms message.
  • template(): Accepts a string value for setting your sms template.
  • type(): Accepts a string value for setting your service type (sms, voice, ...).
  • tokens(): Accepts two string value for setting your tokens. Second string is optional and in case you don't provide it, it set your default token.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email morteza.poussaneh@gmail.com instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 3.71k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固