ayles-software/laravel-sms-mobile-message 问题修复 & 功能扩展

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

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

ayles-software/laravel-sms-mobile-message

最新稳定版本:0.2.0

Composer 安装命令:

composer require ayles-software/laravel-sms-mobile-message

包简介

MobileMessage Notifications channel for Laravel 12

README 文档

README

This package makes it easy to send notifications using MobileMessage with Laravel 12.

Installation

Install the package via composer:

composer require ayles-software/laravel-sms-mobile-message

Add your MobileMessage api key, secret and optional default sender sms_from to your config/services.php:

'mobile_message' => [
    'key' => env('MOBILE_MESSAGE_KEY'),
    'secret'  => env('MOBILE_MESSAGE_SECRET'),
    'from' => env('MOBILE_MESSAGE_FROM'),
],

Usage

Use MobileMessageChannel in via() method inside your notification classes. Example:

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use AylesSoftware\MobileMessage\MobileMessageChannel;
use AylesSoftware\MobileMessage\MobileMessageMessage;

class SmsTest extends Notification
{
    public function __construct(public string $token)
    {
    }

    public function via($notifiable)
    {
        return [MobileMessageChannel::class];
    }

    public function toMobileMessage($notifiable)
    {
        return (new MobileMessageMessage)
            ->message("SMS test to user #{$notifiable->id} with token {$this->token} by MobileMessage")
            ->from('Dory');
    }
}

In notifiable model (User), include method routeNotificationForMobileMessage() that returns recipient mobile number:

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

Then send a notification the standard way:

$user = User::find(1);

$user->notify(new SmsTest);

Events

Following events are triggered by Notification. By default:

  • Illuminate\Notifications\Events\NotificationSending
  • Illuminate\Notifications\Events\NotificationSent

NotificationFailed will trigger if something goes wrong

  • Illuminate\Notifications\Events\NotificationFailed

Testing

Nope

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-16