davidpella/beem-sms-laravel 问题修复 & 功能扩展

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

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

davidpella/beem-sms-laravel

Composer 安装命令:

composer require davidpella/beem-sms-laravel

包简介

Provides Beem notification channel for Laravel

README 文档

README

This package makes it easy to send Beem SMS notifications with Laravel 8.x

Sending an SMS to a user becomes as simple as using:

use App\Notifications\AccountCreated;
 
$user->notify(new AccountCreated);

Or on-demand notifications

use App\Notifications\AccountCreated;
use Illuminate\Support\Facades\Notification;

Notification::route("beem-sms", "255762000000")->notify(new AccountCreated);

Installation

You can install the package via composer:

composer require davidpella/beem-sms-laravel

Configuration

Add your Beem Account api_key, api_secret, and source_address to your .env:

BEEM_SMS_SOURCE_ADDRESS=
BEEM_SMS_API_KEY=
BEEM_SMS_SECRET_KEY=

Advanced configuration

Run to public configuration file config directory

php artisan vendor:publish --provider="DavidPella\BeemSms\BeemSmsServiceProvider"

Usage

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

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use DavidPella\BeemSms\Channel\BeemSmsChannel;
use Illuminate\Notifications\Notification;
use DavidPella\BeemSms\Channel\BeemSmsMessage;

class AccountCreated extends Notification
{
    use Queueable;

    public function via($notifiable):array
    {
        return [BeemSmsChannel::class]; // or ["beem-sms"]
    }

    public function toBeemSms($notifiable):BeemSmsMessage
    {
        return (new BeemSmsMessage())
            ->content("Your {$notifiable->name} account was created!");
    }
}

In order to let your Notification know which phone are you sending to, the channel will look for the phone attribute of the Notifiable model.

If you want to override this behaviour, add the routeNotificationForBeemSms method to your Notifiable model.

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;
    
    public function routeNotificationForBeemSms()
    {
        return $this->phone_number;
    }
}

Or

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;
    
    public function routeNotificationForBeemSms()
    {
        return "255762000000";
    }
}

Available message methods

To use the Beem Sms Client Library you can use the facade:

use DavidPella\BeemSms\Facades\BeemSms;

BeemSms::send([
    "recipient" => "255762000000",
    "message" => "Using the facade to send a message.",
]);

Or request the instance from the service container

app("DavidPella\BeemSms\BeemSmsClient")
    ->recipient("255762000000")
    ->message("Send sms message using laravel service container")
    ->dispatch();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固