/channels

Submit suggestions & pull requests here for new notification channels

Primary LanguagePHPMIT LicenseMIT

UNIFONIC notification 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 Unifonic Api with Laravel 5.5+, 6.x, 7.x and 8.x

Contents

Requierements

  • Before start you have to create an account on Unifonic.

Installation

  1. You can install the package via composer:
composer require laravel-notification-channels/unifonic

Setting up the Unifonic service

Add your Unifonic AppsId to your config/services.php:

// config/services.php
...
'unifonic' => [
    'appsId' => env('UNIFONIC_APPS_ID'),
],
...

Usage

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

use NotificationChannels\Unifonic\UnifonicChannel;
use NotificationChannels\Unifonic\UnifonicMessage;
use Illuminate\Notifications\Notification;

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

    public function toUnifonic($notifiable)
    {
        return UnifonicMessage::create("Your invoice {$notifiable->order->id} was paid!");
    }
}

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

Important note: Unifonic requires the recipients phone number to be E.164

// app/Models/User.php
public function routeNotificationForUnifonic()
{
    return '+21267064497';
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

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