premgthb/exabytes-sms 问题修复 & 功能扩展

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

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

premgthb/exabytes-sms

Composer 安装命令:

composer require premgthb/exabytes-sms

包简介

Laravel package for generating SMS using Exabytes API

README 文档

README

composer require premgthb/exabytes-sms

USAGE

Publish config files:

php artisan vendor:publish --provider="Premgthb\ExabytesSms\ExabytesServiceProvider"

.env Values:

EXABYTES_SMS_USERNAME = Your account username
EXABYTES_SMS_PASSWORD = Your account password

Set up Notification class in your Laravel application using

php artisan make:notification ExabytesSmsNotification

and copy the code as follows

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Premgthb\ExabytesSms\Notifications\ExabytesSmsChannel;

class ExabytesSmsNotification extends Notification
{
    use Queueable;

    public $content;

    public function __construct($message)
    {
        $this->message = $message;
    }

    /**
     * Get the notification's delivery channels.
     */
    public function via($notifiable)
    {
        return [ExabytesSmsChannel::class];
    }

     /**
      * Get SMS Message content
      */
    public function toExabytes($notifiable)
    {
       return $this->message;
    }
}

In your User.php model:

public function routeNotificationForExabytes()
{
   return preg_replace('/\D+/', '', '6'.$this->mobile_number);
}

Finally use the following snippet in your controllers to trigger the Notification

Notification::route('exabytes', $mobileNumber)->notify(new ExabytesSmsNotification($yourMessage));

You are good to go!

ADDITIONAL

To generate 4 digit OTP code, in your controller:

use Exabytes;

$otp = Exabytes::generateOtp();

To Send SMS without Queue:

$data = [ 'to' => $request->mobile_number , 'msg' => $request->message ]

Exabytes::sendMessage($data);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固