mobtexting/mobtexting-laravel
| Install | |
|---|---|
composer require mobtexting/mobtexting-laravel |
|
| Latest Version: | v1.0.5 |
| PHP: | ^7.4|^8.0|^8.1 |
| License: | MIT |
| Last Updated: | Sep 13, 2023 |
| Links: | GitHub · Packagist |
Mobtexting notifications channel for Laravel 5.3+
This package makes it easy to send Mobtexting notifications with Laravel 5.3.
Contents
Installation
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,
],
Setting up your Mobtexting account
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
],
...
Usage
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';
}
Available Message methods
MobtextingSmsMessage
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).
Testing
$ composer test
Security
If you discover any security related issues, please email support@mobtexting.com instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
Related Packages
laravel-paypalpayment is simple package help you process direct credit card paym...
Powerful PHP database abstraction layer (DBAL) with many features for database s...