This package makes it easy to send Mobtexting notifications with Laravel 5.3.
You can install the package via composer:
composer require mobtexting/mobtexting-laravel
Add the service provider (only required on Laravel 5.4 or lower):
// config/app.php
'providers' => [
...
NotificationChannels\Mobtexting\MobtextingProvider::class,
],
Add your Mobtexting Auth Token, and From Number (optional) to your config/services.php
:
// config/services.php
...
'mobtexting' => [
'username' => env('MOBTEXTING_USERNAME'), // optional when using auth token
'password' => env('MOBTEXTING_PASSWORD'), // optional when using auth token
'token' => env('MOBTEXTING_AUTH_TOKEN'), // optional when using username and password
'from' => env('MOBTEXTING_FROM'), // optional
'service' => env('MOBTEXTING_SERVICE'), // optional
],
...
Now you can use the channel in your via()
method inside the notification:
use NotificationChannels\Mobtexting\MobtextingChannel;
use NotificationChannels\Mobtexting\MobtextingSmsMessage;
use Illuminate\Notifications\Notification;
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [MobtextingChannel::class];
}
public function toMobtexting($notifiable)
{
return (new MobtextingSmsMessage())
->text("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_number
attribute and mobile
of the Notifiable model. If you want to override this behaviour, add the routeNotificationForMobtexting
method to your Notifiable model.
public function routeNotificationForMobtexting()
{
return '+1234567890';
}
from('')
: Accepts a phone to use as the notification sender.text('')
: Accepts a string value for the notification body.to('')
: Accepts a string value for the notification to (over writes default).
$ 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.