This package makes it easy to send [Sms notifications] with Laravel 9.0.
You can install the package via composer:
composer require grupodkt/notification-channel-sms
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'),
],
...
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;
}
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.
Please see CHANGELOG for more information what has changed recently.
If you discover any security related issues, please email carodas@grupodkt.com instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.