andriichuk/laravel-letsads-sms-channel

Laravel notification channel for LetsAds SMS API

Maintainers

Package info

github.com/andriichuk/laravel-letsads-sms-channel

pkg:composer/andriichuk/laravel-letsads-sms-channel

Fund package maintenance!

andriichuk

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

dev-main 2026-04-04 09:50 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package makes it easy to send SMS notifications using LetsAds from your Laravel application, using Laravel's built-in notification system.

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

$user->notify(new Invitation());

Installation

You can install the package via composer:

composer require andriichuk/laravel-letsads-sms-channel

The service provider will be auto-discovered by Laravel.

Setting up the LetsAds service

Add your LetsAds SMS credentials to the services.php config file:

// config/services.php

return [
    // ...

    'letsads' => [
        'login' => env('LETSADS_SMS_LOGIN'),
        'password' => env('LETSADS_SMS_PASSWORD'),
        'from' => env('LETSADS_SMS_FROM'),
    ],
];

login is the phone number of your LetsAds account (digits, e.g. 380501234567). from is your registered sender name. API access must be enabled in your LetsAds account.

Then add the corresponding environment variables to your .env:

LETSADS_SMS_LOGIN="380501234567"
LETSADS_SMS_PASSWORD="your-api-password"
LETSADS_SMS_FROM="Your Sender Name"

Usage

Notifiable model

In your notifiable model (typically User), add the routeNotificationForLetsAds method that returns a full mobile number including country code:

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

class User extends Authenticatable
{
    use Notifiable;

    public function routeNotificationForLetsAds(): string
    {
        return $this->phone; // e.g. +380991112233
    }
}

Notification class

Within your notification, add the LetsAds channel to the via method and implement toLetsAds to build the SMS message:

use Andriichuk\LetsAdsSmsChannel\LetsAdsChannel;
use Andriichuk\LetsAdsSmsChannel\Sms;
use Illuminate\Notifications\Notification;

class Invitation extends Notification
{
    public function via($notifiable): array
    {
        return [LetsAdsChannel::class];
    }

    public function toLetsAds($notifiable): Sms
    {
        return new Sms(
            text: 'You have been invited!',
        );
    }
}

Now you can send an SMS notification to a user:

$user->notify(new Invitation());

Anonymous notifications

You can also send SMS messages to phone numbers that are not associated with a notifiable model:

use Illuminate\Support\Facades\Notification;

Notification::route(LetsAdsChannel::class, '+380991112233')
    ->notify(new Invitation());

The channel resolves the recipient phone from the notifiable (via routeNotificationFor(LetsAdsChannel::class) or the notifiable’s string form), so your toLetsAds method can stay the same and omit the phone argument.

Available message options

The Sms value object supports:

  • text (string) – the message body.
  • phone (string, optional) – recipient phone number including country code; if omitted, the channel resolves it from the notifiable.
  • from (string, optional) – sender name for this message only; if omitted, the default from config/services.php is used.

Testing

Run the test suite with:

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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