nerdify / laravel-smsgateway-notification-channel
This package makes it easy to send notifications using SMS Gateway with Laravel.
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ^6.2
- illuminate/notifications: 5.3 - 5.6
- illuminate/support: 5.3 - 5.6
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2022-11-26 17:32:55 UTC
README
This package makes it easy to send notifications using SMS Gateway with Laravel.
Contents
Requirements
Sign up for a online sms gateway account.
Installation
You can install the package via composer:
composer require nerdify/laravel-smsgateway-notification-channel
You must install the service provider:
// config/app.php 'providers' => [ ... Nerdify\SmsGateway\SmsGatewayServiceProvider::class, ],
Setting up your SMS Gateway account
Add your SMS Gateway email, password, and device ID to your config/services.php
:
// config/services.php ... 'smsgateway' => [ 'email' => env('SMSGATEWAY_EMAIL'), 'password' => env('SMSGATEWAY_PASSWORD'), 'device' => env('SMSGATEWAY_DEVICE'), ], ...
Usage
You can use the channel in your via()
method inside the notification:
use Illuminate\Notifications\Notification; use Nerdify\SmsGateway\SmsGatewayChannel; use Nerdify\SmsGateway\SmsGatewayMessage; class InvoicePaid extends Notification { public function via($notifiable) { return [SmsGatewayChannel::class]; } public function toSmsGateway($notifiable) { return (new SmsGatewayMessage) ->content('Your invoice has been paid!'); } }
When sending notifications, the notification system will automatically look for a phone_number attribute on the notifiable entity. If you would like to customize the phone number the notification is delivered to, define a routeNotificationForSmsGateway
method on the entity:
public function routeNotificationForSmsGateway() { return '+1234567890'; }
Available Message methods
SmsGatewayMessage
content()
: The content of the message to be sent.expiresAt()
: Time to give up trying to send the message at in Unix Time format.sendAt()
: Time to send the message in Unix Time format.
License
The MIT License (MIT). Please see License File for more information.