enniel/laravel-asterisk-notification-channel

0.1.1 2017-02-03 05:52 UTC

This package is auto-updated.

Last update: 2024-11-06 03:59:14 UTC


README

This package makes it easy to send notifications using Asterisk Manager Interface (AMI) and Asterisk Chan Dongle with Laravel 5.3.

Contents

Installation

You can install this package via composer:

composer require enniel/laravel-asterisk-notification-channel

Next add the service provider to your config/app.php:

...
'providers' => [
    ...
     NotificationChannels\Asterisk\AsteriskServiceProvider::class,
],
...

Setting up the Asterisk service

See enniel/ami documentation.

Usage

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

use NotificationChannels\Asterisk\AsteriskChannel;
use NotificationChannels\Asterisk\AsteriskMessage;
use Illuminate\Notifications\Notification;

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

    public function toAsterisk($notifiable)
    {
        return AsteriskMessage::create('message text');
    }
}

In order to let your Notification know which phone number you are targeting, add the routeNotificationForAsterisk method to your Notifiable model.

Important note: Asterisk requires the recipients phone number to be in international format. For instance: 0031612345678

public function routeNotificationForAsterisk()
{
    return '0031612345678';
}

Available message methods

  • content('test'): Set message text.
  • device('modem1'): Set device for sending SMS message.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.