andriichuk / laravel-letsads-sms-channel
Laravel notification channel for LetsAds SMS API
Package info
github.com/andriichuk/laravel-letsads-sms-channel
pkg:composer/andriichuk/laravel-letsads-sms-channel
Fund package maintenance!
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.9
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
This package is auto-updated.
Last update: 2026-04-04 12:42:36 UTC
README
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 fromconfig/services.phpis 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.