laravel-wesender maintained by ravelino
Wesender for Laravel
This package allows you to use Wesenderons with Laravel (tested in version 8) to send SMS.
Contents
Installation
You can install the package via composer:
composer require ravelino/laravel-wesender
Configuration
Add your ApKey to your .env:
WESENDER_API_KEY=******************************
WESENDER_SPECIAL_CHARACTERS=true
Advanced configuration
Run php artisan vendor:publish --provider="Ravelino\Wesender\WesenderProvider"
/config/wesender.php
Usage
Now you can use the channel in your via() method inside the notification:
use Ravelino\Wesender\WesenderChannel;
use Ravelino\Wesender\WesenderSmsMessage;
use Illuminate\Notifications\Notification;
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [WesenderChannel::class];
}
public function toWesender($notifiable)
{
return (new WesenderSmsMessage())
->content("Hello world!");
}
}
In order to let your Notification know which phone are you sending, the channel will look for the phone_number attribute of the Notifiable model. If you want to override this behaviour, add the routeNotificationForWesender method to your Notifiable model.
public function routeNotificationForWesender()
{
return '+1234567890';
}
Available Message methods
WesenderSmsMessage
content(''): Accepts a string value for the notification body.
Testing
$ composer test
Security
If you discover any security related issues, please email gregoriohc@gmail.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.