This package makes it easy to send notifications using SparrowSMS with Laravel 7.0, 8.0
You can install this package via composer:
composer require laravel-notification-channels/sparrowsms
Add your SparrowSMS api endpoint, token and from to your .env file or config/services.php:
// config/services.php
...
'sparrowsms' => [
'endpoint' => env('SPARROW_SMS_ENDPOINT'),
'token' => env('SPARROW_SMS_TOKEN'),
'from' => env('SPARROW_SMS_FROM'),
],
...
You can use the channel in your via() method inside the notification:
use Illuminate\Notifications\Notification;
use NotificationChannels\SparrowSMS\SparrowSMSMessage;
class AccountApproved extends Notification
{
public function via($notifiable)
{
return ["sparrowsms"];
}
public function toSparrowSMS($notifiable)
{
return (new SparrowSMSMessage("Your account was approved!"));
}
}
In your notifiable model, make sure to include a routeNotificationForSparrowSMS() method, which returns a phone number or an array of phone numbers.
public function routeNotificationForTurboSMS()
{
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('sparrow', '+9779841100000')
->notify(new AccountApproved());
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.