dash8x/dhiraagu-sms-notification

Laravel notification channel for Dhiraagu Bulk SMS Gateway

v0.5.0 2024-04-14 10:05 UTC

README

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 Dhiraagu Bulk SMS Gateway with Laravel 5.3.

Contents

Installation

You can install the package via composer:

composer require dash8x/dhiraagu-sms-notification

Add the service provider (only required on Laravel 5.4 or lower):

// config/app.php
'providers' => [
    ...
    Dash8x\DhiraaguSmsNotification\DhiraaguSmsNotificationServiceProvider::class,
],

Optionally add the facade.

// config/app.php
'aliases' => [
    ...
    'DhiraaguSms' => Dash8x\DhiraaguSmsNotification\Facades\DhiraaguSms::class,
],

Setting up the Dhiraagu Bulk Sms Gateway credentials

Add your Dhiraagu Bulk SMS Gateway Account Username, Password, and Url (optional) to your config/services.php:

// config/services.php
...
'dhiraagu' => [
    'username' => env('DHIRAAGU_SMS_USERNAME'), // Bulk SMS gateway username, usually same as your sender name 
    'password' => env('DHIRAAGU_SMS_PASSWORD'), // Bulk SMS gateway password
    'url' => env('DHIRAAGU_SMS_URL'), // optional, use only if you need to override the default,
                                      // defaults to https://bulkmessage.dhiraagu.com.mv/partners/xmlMessage.jsp   
],
...

Usage

Now you can use the channel in your via() method inside the notification:

use Dash8x\DhiraaguSmsNotification\DhiraaguSmsNotificationChannel;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [DhiraaguSmsNotificationChannel::class];
    }

    public function toDhiraagu($notifiable)
    {
        return "Your {$notifiable->service} account was approved!";
    }
}

In order to let your Notification know which phone are you sending to, the channel will look for the phone_number attribute of the Notifiable model. If you want to override this behaviour, add the routeNotificationForDhiraagu method to your Notifiable model.

public function routeNotificationForDhiraagu()
{
    return '+9607777777';
}

It also supports sending to multiple phone numbers.

public function routeNotificationForDhiraagu()
{
    return ['+9607777777', '+9609999999'];
}

Available Message methods

DhiraaguSmsNotificationMessage

  • setNumbers(''): Accepts phone numbers to use as the notification recipients.
  • setMessage(''): Accepts a string value for the notification body.
  • getNumbers(): Returns the recipients.
  • getMessage(): Returns the string value of the notification body.

Checking delivery status

To proccess any laravel notification channel response check Laravel Notification Events This channel returns a DhiraaguSmsMessage response object.

Check dash8x/dhiraagu-sms for Delivery Status Checking Documentation.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

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

Disclaimer

This package is not in any way officially affiliated with Dhiraagu. The "Dhiraagu" name has been used under fair use.