PHP code example of aaqib / geo-pakistan

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

    

aaqib / geo-pakistan example snippets


composer 

'providers' => [
    // ...
    Aaqib\GeoPakistan\GeoPakistanServiceProvider::class,
]

php artisan vendor:publish --force --provider="Aaqib\GeoPakistan\GeoPakistanServiceProvider"
composer dump-autoload
php artisan geopakistan:init

use Aaqib\GeoPakistan\Pakistan;

Pakistan::Provinces()


use Aaqib\GeoPakistan\Division;

Pakistan::Divisions()

use Aaqib\GeoPakistan\Models\Province;

$punjab = Province::getByAbbr('PUN');
$divisions = $punjab->divisions()->get();
// or use children method
$divisions = $punjab->children();

    $rawalpindi = Division::getByName('Rawalpindi');
    $punjab = $rawalpindi->parent();

// get district by tehsil
$lahore_city = Tehsil::getByName('Lahore City');
$Lahore = $lahore_city->district();

// get division by tehsil
$lahore_city = Tehsil::getByName('Lahore City');
$lahore = $lahore_city->division();

// get province by tehsil
$lahore_city = Tehsil::getByName('Lahore City');
$Punjab = $lahore_city->province();

// get by province
$punjab = Province::getByAbbr('PUN');
$tehsils = $punjab->tehsils()->get();

// get by division
$rawalpindi = Division::getByName('Rawalpindi');
$tehsils = $rawalpindi->tehsils()->get();