grupodkt / notification-channel-sms
Notification channel SMS
Requires
- php: ^8.0.2
- guzzlehttp/guzzle: ^7.2
- illuminate/notifications: *
Requires (Dev)
- mockery/mockery: ^1.4.4
- phpunit/phpunit: ^9.5.10
This package is not auto-updated.
Last update: 2024-11-05 06:00:44 UTC
README
This package makes it easy to send [Sms notifications] with Laravel 9.0.
Contents
Installation
You can install the package via composer:
composer require grupodkt/notification-channel-sms
Setting up your Waba account
Add your Sms Url, Auth Token, and phoneNumberId to your config/services.php
:
// config/services.php ... 'sms' => [ 'url' => env('SMS_URL'), 'token' => env('SMS_TOKEN'), 'phoneNumberId' => env('SMS_PHONE_NUMBER_ID'), ], ...
Usage
Now you can use the channel in your via()
method inside the notification:
use NotificationChannels\Sms\SmsChannel; use NotificationChannels\Sms\SmsMessage; use Illuminate\Notifications\Notification; class AccountApproved extends Notification { public function via($notifiable) { return [SmsChannel::class]; } public function toSms($notifiable) { return (new SmsMessage()) ->content("Your {$notifiable->service} account was approved!"); } }
In order to let your Notification know which phone are you sending/calling to, the channel will look for the celular
attribute of the Notifiable model. If you want to override this behaviour, add the routeNotificationForSms
method to your Notifiable model.
public function routeNotificationForSms() { return $this->celular; }
Available Message methods
SmsMessage
from('')
: Accepts a phone to use as the notification sender.content('')
: Accepts a string value for the notification body.idCode(0)
: Accepts a integer value for the correlative id message.
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security related issues, please email carodas@grupodkt.com instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.