Skip to content

shankhadevpadam/sparrowsms

Repository files navigation

SparrowSMS Notifications Channel for Laravel

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads

This package makes it easy to send notifications using SparrowSMS with Laravel 7.0, 8.0

Contents

Installation

You can install this package via composer:

composer require laravel-notification-channels/sparrowsms

Setting up the SparrowSMS service

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'),
    ],
...

Usage

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;
}

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('sparrow', '+9779841100000')                      
            ->notify(new AccountApproved());

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email shankhadev123@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.

Releases

No releases published

Packages

No packages published

Languages