PHP code example of larament / barta

1. Go to this page and download the library: Download larament/barta 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/ */

    

larament / barta example snippets


use Larament\Barta\Facades\Barta;

Barta::to('01712345678')
    ->message('Your OTP is 1234')
    ->send();

Barta::driver('DRIVER_NAME')
    ->to('01712345678')
    ->message('Hello from Larament Barta')
    ->send();

Barta::to('01712345678')
    ->message('Queued message')
    ->queue();

Barta::to(['01712345678', '01812345678'])
    ->message('Hello everyone!')
    ->send();

use Illuminate\Notifications\Notification;
use Larament\Barta\Notifications\BartaMessage;

class OrderShipped extends Notification
{
    public function via(object $notifiable): array
    {
        return ['barta'];
    }

    public function toBarta(object $notifiable): BartaMessage
    {
        return new BartaMessage('Your order has been shipped!');
    }
}

public function routeNotificationForBarta($notification): string
{
    return $this->phone;
}
bash
php artisan barta:install