PHP code example of princeton255 / laravel-notifications-infobip

1. Go to this page and download the library: Download princeton255/laravel-notifications-infobip 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/ */

    

princeton255 / laravel-notifications-infobip example snippets


// config/services.php
...
'infobip' => [
    'username' => env('INFOBIP_USERNAME'),
    'password' => env('INFOBIP_PASSWORD'),
    'from' => env('INFOBIP_FROM', 'IBTEST'),
],
...

...
'infobip' => [
    ...
    'baseUrl' => env('INFOBIP_BASE_URL', null),
],
...

public function routeNotificationForInfobip()
{
    return '+1234567890';
}

use App\Notifications\ExampleInfobipNotification;
use Illuminate\Support\Facades\Notification;

Notification::send($user, new ExampleInfobipNotification());

// where $user implements `Illuminate\Notifications\Notifiable` trait

use App\Notifications\ExampleInfobipNotification;

$user->notify(new ExampleInfobipNotification($invoice));



namespace App\Notifications;

use Illuminate\Notifications\Notification;
use NotificationChannels\Infobip\InfobipChannel;
use NotificationChannels\Infobip\InfobipMessage;

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

    public function toInfobip($notifiable)
    {
        return (new InfobipMessage())
            // Customize your msg content here
            ->content("Your {$notifiable->service} account was approved!"); 
    }
}



namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;
}
 php
use NotificationChannels\Infobip\InfobipChannel;
use NotificationChannels\Infobip\InfobipMessage;
use Illuminate\Notifications\Notification;

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

    public function toInfobip($notifiable)
    {
        return (new InfobipMessage())
            ->content("Your {$notifiable->service} account was approved!");
    }
}