enniel / laravel-asterisk-notification-channel by enniel

Asterisk Notifications Driver
1,650
7
4
Package Data
Maintainer Username: enniel
Maintainer Contact: razumov.evgeni@gmail.com (Evgeni Razumov (Enniel))
Package Create Date: 2016-09-06
Package Last Update: 2017-02-03
Language: PHP
License: MIT
Last Refreshed: 2024-04-27 03:07:25
Package Statistics
Total Downloads: 1,650
Monthly Downloads: 3
Daily Downloads: 0
Total Stars: 7
Total Watchers: 4
Total Forks: 1
Total Open Issues: 0

Asterisk notification channel for Laravel 5.3

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.