PHP code example of pirumart / uganda-administrative-units

1. Go to this page and download the library: Download pirumart/uganda-administrative-units 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/ */

    

pirumart / uganda-administrative-units example snippets


use Pirumart\Uganda\Locale\Models\District;

$district = District::where('district_code', 'D01')->first();

$district->region()->first(); // parent Region
$district->counties;          // child Counties
$district->sub_counties;      // child SubCounties
$district->parishes;          // child Parishes
$district->villages;          // child Villages

use Pirumart\Uganda\Locale\Models\Village;

$village = Village::where('village_code', 'V01')->first();

$village->district;    // parent District
$village->county;      // parent County
$village->sub_county;  // parent SubCounty
$village->parish;      // parent Parish

$district->region()->first();

use Pirumart\Uganda\Locale\Database\Seeders\UgandaLocaleSeeder;

(new UgandaLocaleSeeder())->run();

use Pirumart\Uganda\Locale\Models\Village;

Village::factory()->create(); // a single fake village, no seeding 
bash
php artisan vendor:publish --provider="Pirumart\Uganda\Locale\AdministrativeUnitsServiceProvider" --tag="administrative-units-migrations"
php artisan migrate
bash
php artisan uganda-administrative-units:seed