承接 lotuashvili/laravel-smsoffice 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

lotuashvili/laravel-smsoffice

Composer 安装命令:

composer require lotuashvili/laravel-smsoffice

包简介

SMSOffice.ge Service and Notification channel for Laravel

README 文档

README

Latest Stable Version Total Downloads Downloads Month

This package allows you to send SMS messages with SmsOffice.ge API

You can send sms with notification class or directly with SmsOffice class

Laravel SmsOffice

Table of Contents

Installation

composer require lotuashvili/laravel-smsoffice

For Laravel <= 5.4

If you're using Laravel 5.4 or lower, you have to manually add a service provider in your config/app.php file. Open config/app.php and add SmsOfficeServiceProvider to the providers array.

'providers' => [
    # Other providers
    Lotuashvili\LaravelSmsOffice\SmsOfficeServiceProvider::class,
],

Then run:

php artisan vendor:publish --provider="Lotuashvili\LaravelSmsOffice\SmsOfficeServiceProvider"

Place your api key and sender name in config/smsoffice.php file

Development mode config

If you want to use log in development instead of sending real sms, then add SMSOFFICE_DRIVER=log to your .env file

Usage

Send with notification class

In User class, add routeNotificationForSms() method and return phone number of user

class User extends Authenticatable
{
    # Code...

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

Create notification

php artisan make:notification FooNotification

In our newly created notification, import SmsOfficeChannel and add it to via() method. Write notification content in toSms() method

use Illuminate\Notifications\Notification;
use Lotuashvili\LaravelSmsOffice\SmsOfficeChannel;

class FooNotification extends Notification
{
    public function via($notifiable)
    {
        return [SmsOfficeChannel::class];
    }
    
    public function toSms($notifiable)
    {
        return 'Test Notification';
    }
}

And then send notification to user

$user->notify(new FooNotification)

Send directly without notification

You have to inject or initialize SmsOffice class and then call send function

use Lotuashvili\LaravelSmsOffice\SmsOffice;

public function sendSms(SmsOffice $smsoffice)
{
    $smsoffice->send('599123123', 'Test Message');
}

Get Balance

use Lotuashvili\LaravelSmsOffice\SmsOffice;

public function getBalance(SmsOffice $smsoffice)
{
    $smsoffice->balance();
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-11-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固