PHP code example of aswadwk / indonesiaregion

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

    

aswadwk / indonesiaregion example snippets


use App\Models\Province;

$provinces = Province::all();                    // 38 provinsi
$province  = Province::find('93');               // PAPUA SELATAN

$province->regencies;                            // hasMany
$province->districts;                            // hasManyThrough

use App\Models\District;

$district = District::find('110101');            // BAKONGAN
$district->isProvince('11');                     // true
$district->isRegency('1101');                    // true
$district->villages;                             // hasMany
bash
php artisan indoregion:publish
bash
php artisan migrate
bash
php artisan db:seed --class="Database\Seeders\IndoRegionSeeder"