undjike / lmt-laravel-notification-channel
Laravel Notification Channel based on LMT SMS service
v1.0.2
2024-10-13 05:28 UTC
Requires
- php: >=8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.8
- illuminate/notifications: >=9.52
- illuminate/support: >=9.52
Requires (Dev)
- mockery/mockery: >=1.6
- phpunit/phpunit: >=9.6
README
Introduction
This is a package for Laravel Applications which enables you to send notifications through LMT SMS Channel.
The package uses LMT API Service to perform SMS dispatching.
Installation
This package can be installed via composer. Just type :
composer require undjike/lmt-laravel-notification-channel
Usage
After installation, configure your services in congig/services.php
by adding :
<?php return [ //... 'lmt' => [ 'key' => env('LMT_API_KEY'), // Your credentials are expected here 'secret' => env('LMT_API_SECRET') ], ];
Once this is done, you can create your notification as usual.
<?php namespace App\Notifications; use Illuminate\Notifications\Notification; use Undjike\LmtNotificationChannel\LmtChannel; use Undjike\LmtNotificationChannel\LmtMessage; class LmtNotification extends Notification { /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [LmtChannel::class]; // or return 'lmt'; } /** * @param $notifiable * @return mixed */ public function toLmt($notifiable) { return LmtMessage::create() ->body('Type here you message content...') ->sender('Brand name'); // or return 'Type here you message content...'; } }
To get this stuff completely working, you need to add this to your notifiable model.
/** * Attribute to use when addressing LMT SMS notification * * @returns string|array */ public function routeNotificationForLmt() { return $this->phone_number; // Can be a string or an array of valid phone numbers }
Enjoy !!!
License
The MIT License (MIT). Please see License File for more information.