PHP code example of kejubayer / steadfast-api-integration

1. Go to this page and download the library: Download kejubayer/steadfast-api-integration 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/ */

    

kejubayer / steadfast-api-integration example snippets


use Kejubayer\Steadfast\Facades\Steadfast;

$parcel = Steadfast::createParcel([
    'invoice' => 'INV-1001',
    'recipient_name' => 'Customer Name',
    'recipient_phone' => '01700000000',
    'recipient_address' => 'Dhaka, Bangladesh',
    'cod_amount' => 1500,
]);

$bulk = Steadfast::bulkCreate([
    [
        'invoice' => 'INV-1002',
        'recipient_name' => 'Customer One',
        'recipient_phone' => '01700000000',
        'recipient_address' => 'Dhaka, Bangladesh',
        'cod_amount' => 1500,
    ],
    [
        'invoice' => 'INV-1003',
        'recipient_name' => 'Customer Two',
        'recipient_phone' => '01800000000',
        'recipient_address' => 'Chattogram, Bangladesh',
        'cod_amount' => 2200,
    ],
]);

$status = Steadfast::track('12345');

$status = Steadfast::trackByInvoice('INV-1001');

$status = Steadfast::trackByTrackingCode('tracking-code');

$balance = Steadfast::getBalance();

use Kejubayer\Steadfast\Models\SteadfastParcelStatus;

$latestStatus = SteadfastParcelStatus::where('invoice', 'INV-67890')
    ->latest('provider_updated_at')
    ->first();

$history = SteadfastParcelStatus::where('consignment_id', '12345')
    ->orderBy('provider_updated_at')
    ->get();

use GuzzleHttp\Exception\GuzzleException;
use JsonException;

try {
    $parcel = Steadfast::createParcel($data);
} catch (GuzzleException|JsonException $exception) {
    report($exception);
}
bash
php artisan vendor:publish --tag=steadfast-config
text
config/steadfast.php
bash
php artisan migrate
bash
php artisan vendor:publish --tag=steadfast-migrations
text
POST /steadfast/webhook