PHP code example of shiroamada / green-api-laravel-notification

1. Go to this page and download the library: Download shiroamada/green-api-laravel-notification library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shiroamada / green-api-laravel-notification example snippets


// config/app.php
'providers' => [
    ...
    NotificationChannels\GreenApi\GreenApiServiceProvider::class,
],

// 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'),
],
...

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!");
    }
}

public function routeNotificationForGreenApi()
{
    return $this->mobile; //depend what is your db field
}