This package makes it easy to send notifications using Textlocal with Laravel framework.
You can install the package via composer:
composer require chitranu/textlocal-laravel-notification-channel
Add your Textlocal API key and sender to your config/services.php
:
<?php
return [
// ...
'textlocal' => [
'key' => env('TEXTLOCAL_KEY'),
'sender' => env('TEXTLOCAL_SENDER'),
],
];
Now you can use the channel in your via()
method inside the notification:
<?php
use NotificationChannels\Textlocal\TextlocalChannel;
use NotificationChannels\Textlocal\TextlocalMessage;
use Illuminate\Notifications\Notification;
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [TextlocalChannel::class];
}
public function toSms($notifiable)
{
// OR explicitly return a TextlocalMessage object passing the message body:
return new TextlocalMessage("Your {$notifiable->service} account was approved!");
}
}
In order to let your Notification know which phone are you sending to, the channel
will look for the phone
, mobile
, phone_number
or full_phone
attribute of the
Notifiable model. If you want to override this behaviour, add the
routeNotificationForTextlocal
method to your Notifiable model.
<?php
use Illuminate\Notifications\Notifiable;
class SomeModel {
use Notifiable;
public function routeNotificationForTextlocal($notification)
{
return '+1234567890';
}
}
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.