定制 madbob/laravel-notification-mobyt 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

madbob/laravel-notification-mobyt

Composer 安装命令:

composer require madbob/laravel-notification-mobyt

包简介

Integration with Laravel Notifications and Esendex/Mobyt/Skebby/SMSItalia SMS gateways

README 文档

README

This package integrates the Esendex SMS Gateway service (formerly known as Mobyt, from which the name of the package) to the native Laravel Notifications system, so to be able to dispatch your notification with a simple $user->notify(new YourNotification()).

The library is compatible with other SMS services using the same API, including:

Installation

composer require madbob/laravel-notification-mobyt

Configuration

In your config/services.php file, add the following block:

'mobyt' => [
    /*
        Identifier of one of the supported SMS services:
        esendex
        skebby
        mobyt // Mobyt no longer exists, this is kept for historical reasons and acts as the "esendex" driver
        smsitaly // SMSItalia no longer exists, this is kept for historical reasons and acts as the "esendex" driver
    */
    'driver' => 'esendex',

    /*
        Custom name to display as "sender"
    */
    'from' => 'YourName',

    /*
        Username for your account
    */
    'username' => env('MOBYT_USERNAME'),

    /*
        Password for your account
    */
    'password' => env('MOBYT_PASSWORD'),
],

Usage

Add a toMobyt() function to the Notification you want to deliver via SMS, and add the MobytChannel class to the channels involved.

use MadBob\LaravelNotification\Mobyt\MobytChannel;
use MadBob\LaravelNotification\Mobyt\MobytMessage;
use Illuminate\Notifications\Notification;

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

    public function toMobyt($notifiable)
    {
        return (new MobytMessage())->content("Your message here!");
    }
}

In order to let your notification know which phone number are you sending to, the channel will look for the phone_number attribute of the Notifiable model. If you want to override this behaviour, add the routeNotificationForMobyt() method to your Notifiable model.

public function routeNotificationForMobyt()
{
    return '+1234567890';
}

The MobytMessage object has other options, including:

  • type() to specify the type of message, you can choose among MobytMessage::HI_QUALITY, MobytMessage::MID_QUALITY and MobytMessage::LOW_QUALITY
  • from() to dynamically change the custom name of sender
  • addRecipient() to add more recipients numbers to the message. Always remember to add the international prefix!

License

This code is free software, licensed under the MIT License. See the LICENSE.txt file for more details.

Copyright (C) 2017/2026 Roberto Guido bob@linux.it

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固