Looking to hire Laravel developers? Try LaraJobs

laravel-sms-mobile-message maintained by ayles-software

Description
MobileMessage Notifications channel for Laravel 12
Last update
2026/02/27 12:32 (dev-main)
License
Downloads
192

Comments
comments powered by Disqus

MobileMessage sms notifications channel for Laravel 12

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.