📲 This package makes it easy to send notifications (SMS) using OneWaySMS with Laravel 6.x, 7.x, 8.x and 9.x
You can install this package via composer:
composer require laravel-lib/onewaysms
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')
],
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;
}
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));
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),
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email mr.putera@gmail.com instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.