mobtexting / mobtexting-laravel
A boilerplate for contributions.
Installs: 4 008
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0|^8.1
- illuminate/events: ^7|^8|^9.0
- illuminate/notifications: ^7|^8|^9.0
- illuminate/support: ^7|^8|^9.0
- mobtexting/sdk: ^1.0
This package is auto-updated.
Last update: 2024-10-13 09:32:07 UTC
README
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.