laravel-lib / onewaysms
OneWaySMS Notifications channel for Laravel
Requires
- php: ^7.4 || ^8.0
- guzzlehttp/guzzle: ^6.4 || ^7.0
- illuminate/notifications: 6 - 9
- illuminate/support: 6 - 9
Requires (Dev)
- mockery/mockery: ^1.4
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-03-29 04:46:31 UTC
README
📲 This package makes it easy to send notifications (SMS) using OneWaySMS with Laravel 6.x, 7.x, 8.x and 9.x
Contents
Installation
You can install this package via composer:
composer require laravel-lib/onewaysms
Setting up the OneWaySMS service
Add your OneWaySMS API account and settings to your config/services.php
:
// config/services.php 'onewaysms' => [ 'username' => env('SMS_USERNAME', 'YOUR USERNAME HERE'), 'password' => env('SMS_PASSWORD', 'YOUR PASSWORD HERE'), 'endpoint' => env('SMS_ENDPOINT', 'https://gateway.onewaysms.com.my/api.aspx'), 'sender' => env('SMS_SENDER', 'YOUR SENDER ID') ],
Usage
You can use the channel in your via() method inside the notification:
use Illuminate\Notifications\Notification; use NotificationChannels\Onewaysms\OnewaysmsMessage; class AccountApproved extends Notification { public function via($notifiable) { return ["onewaysms"]; } public function toOnewaysms($notifiable) { return (new OnewaysmsMessage)->content("Your account has been successfully approved !"); } }
In your notifiable model, make sure to include a routeNotificationForOnewaysms() method, which returns a phone number or an array of phone numbers.
public function routeNotificationForOnewaysms() { return $this->phone; }
On-Demand Notifications
Sometimes you may need to send a notification to someone who is not stored as a "user" of your application. Using the Notification::route method, you may specify ad-hoc notification routing information before sending the notification :
Notification::route('onewaysms', '+60123456789') ->notify(new InvoicePaid($invoice));
Available Message methods
to()
: Sets the recipient's mobile no.
from()
: Sets the sender id.
content()
: Set a content of the notification message. This parameter should be no longer than 459 chars (3 message parts),
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email mr.putera@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.