定制 yudina/laravel-sms 二次开发

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

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

yudina/laravel-sms

Composer 安装命令:

composer require yudina/laravel-sms

包简介

Sms provider

关键字:

README 文档

README

This package makes it easy to send SMS notifications for some sms providers with Laravel 5.8.

Supported SMS providers:

Installation

Add SmsNotification package to your Laravel project via composer:

composer required yudina/laravel-sms

Then publish configuration file:

php artisan vendor:publish --provider="Yudina\LaravelSms\SmsSenderServiceProvider"

Settings up your account for select sms provider

Add the environment variables to your config/services.php:

// config/services.php
...
'default' => env('SMS_PROVIDER', 'smscru'),

'providers' => [
    'smsru' => [
        'api_id' => env('SMSRU_API_ID')
    ],
    'smscru' => [
        'login' => env('SMSCRU_LOGIN'),
        'password' => env('SMSCRU_PASSWORD'),
        'sender' => env('SMSCRU_SENDER')
    ],
    ...
]
...

Add your necessary keys to your .env:

 // .env
 SMSRU_API_ID=
 ...

Usage

Now you can use the channel in your via() method inside the notification:

use Yudina\LaravelSms\SmsSenderChannel;
use Yudina\LaravelSms\SmsSenderMessage;

use Illuminate\Notifications\Notification;

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

    public function toSms($notifiable)
    {
        $message = 'Activation code: ' . $this->generateCode(6);
    
        return new SmsSenderMessage($message);
    }
    
    private function generateCode(int $length): string
    {
        $result = '';

        for($i = 0; $i < $length; $i++)
            $result .= mt_rand(0, 9);

        return $result;
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固