shiroamada / green-api-laravel-notification
Green API Notifications channel for Laravel 5.3 and Above
Requires
- php: ^7.3|^8.0
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.2
- illuminate/notifications: 5.1 - 5.8|^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/queue: 5.1 - 5.8|^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/support: 5.1 - 5.8|^6.0|^7.0|^8.0|^9.0|^10.0
Requires (Dev)
- mockery/mockery: ^1.3.1
- phpunit/phpunit: ^9.3
README
This package makes it easy to send notifications using https://green-api.com/en/ with Laravel 5.3+.
Code Reference from laravel-notification-channels/smsc-ru
Contents
Installation
You can install the package via composer:
composer require shiroamada/green-api-laravel-notification
Then you must install the service provider:
// config/app.php 'providers' => [ ... NotificationChannels\GreenApi\GreenApiServiceProvider::class, ],
Setting up the Green API service
Add your green api instanceId and token to your config/services.php
:
// config/services.php ... 'green_api' => [ 'isEnable' => env('GREEN_API_ENABLE') ?? 0, 'instanceId' => env('GREEN_API_INSTANCEID'), 'token' => env('GREEN_API_TOKEN'), 'isMalaysiaMode' => env('GREEN_API_MALAYSIA_MODE') ?? 0, 'isDebug' => env('GREEN_API_DEBUG_ENABLE') ?? 0, 'debugReceiveNumber' => env('GREEN_API_DEBUG_RECEIVE_NUMBER'), ], ...
Usage
You can use the channel in your via()
method inside the notification:
use Illuminate\Notifications\Notification; use NotificationChannels\GreenApi\GreenApiMessage; use NotificationChannels\GreenApi\GreenApiChannel; class AccountApproved extends Notification { public function via($notifiable) { return [GreenApiChannel::class]; } public function toGreenApi($notifiable) { return GreenApiMessage::create("Task #{$notifiable->id} is complete!"); } }
In your notifiable model, make sure to include a routeNotificationForGreenApi() method, which return the phone number.
public function routeNotificationForGreenApi() { return $this->mobile; //depend what is your db field }
Available methods
content()
: Set a content of the notification message.
To send a next new line message, in PHP please use double quote "\n"
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please use the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.