PHP code example of devrkb21 / pathao-laravel

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

    

devrkb21 / pathao-laravel example snippets


// config/app.php — providers array
devrkb21\PathaoLaravel\PathaoLaravelServiceProvider::class,

// config/app.php — aliases array
'PathaoLaravel' => devrkb21\PathaoLaravel\Facades\PathaoLaravel::class,

use devrkb21\PathaoLaravel\Facades\PathaoLaravel;

// Get all cities
PathaoLaravel::GET_CITIES();

// Get zones for a city
PathaoLaravel::GET_ZONES(int $city_id);

// Get areas for a zone
PathaoLaravel::GET_AREAS(int $zone_id);

// Bulk fetch all zones / areas
PathaoLaravel::GET_ZONES_BULK();
PathaoLaravel::GET_AREAS_BULK();

// List stores (with optional pagination)
PathaoLaravel::GET_STORES(int $page = 1);

// Create a new store
// Required: name, contact_name, contact_number, address, city_id, zone_id, area_id
PathaoLaravel::CREATE_STORE($request);

// Create an order
// Required: store_id, recipient_name, recipient_phone, recipient_address,
//           delivery_type (48=Normal, 12=On-Demand), item_type (1=Document, 2=Parcel),
//           item_quantity, item_weight, amount_to_collect
PathaoLaravel::CREATE_ORDER($request);

// Create multiple orders in bulk
PathaoLaravel::CREATE_ORDERS_BULK(array $orders);

// View order details
PathaoLaravel::VIEW_ORDER(string $consignment_id);

// Calculate delivery price
PathaoLaravel::GET_PRICE_CALCULATION($request);

// Get merchant profile info
PathaoLaravel::GET_MERCHANT_INFO();

// Get user success rate by phone
PathaoLaravel::GET_USER_SUCCESS_RATE($request);

// Check token expiry
PathaoLaravel::GET_ACCESS_TOKEN_EXPIRY_DAYS_LEFT();

use devrkb21\PathaoLaravel\Events\PathaoWebhookReceived;

Event::listen(PathaoWebhookReceived::class, function ($event) {
    $payload = $event->payload;

    // Map webhook data to your order status updates
    // $payload['event'], $payload['consignment_id'], $payload['order_status'], etc.
});
bash
php artisan vendor:publish --tag="pathao-config"
bash
php artisan migrate
bash
php artisan pathao:setup