/laravel-netgsm-channel

Submit pull requests here for new notification channels

Primary LanguagePHPMIT LicenseMIT

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 NetGsm with Laravel 5.3 - 5.7.

Contents

Installation

You can install the package via composer:

composer require laravel-notification-channels/netgsm

Setting up the NetGsm service

Add the environment variables to your config/services.php:

// config/services.php
...
'netgsm' => [
    'user_code' => env('NETGSM_USER_CODE'),
    'secret' => env('NETGSM_SECRET'),
    'msg_header' => env('NETGSM_HEADER'),
],
...

Add your NetGsm User Code, Default header (name or number of sender), and secret (password) to your .env:

// .env
...
NETGSM_USER_CODE=
NETGSM_SECRET=
NETGSM_HEADER=
],
...

Usage

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

use NotificationChannels\NetGsm\NetGsmChannel;
use NotificationChannels\NetGsm\NetGsmMessage;
use Illuminate\Notifications\Notification;

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

    public function toNetGsm($notifiable)
    {
        return (new NetGsmMessage("Your {$notifiable->service} was ordered!"));
    }
}

You can add recipients (single value or array)

return (new NetGsmMessage("Your {$notifiable->service} was ordered!"))->setRecipients($recipients);

Additionally you can change header

return (new NetGsmMessage("Your {$notifiable->service} was ordered!"))->setHeader("COMPANY");

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

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