PHP code example of creasi / laravel-nusa

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

    

creasi / laravel-nusa example snippets


use Creasi\Nusa\Models\Province;

// Get all provinces
$provinces = Province::all();

// Search by name or code
$jateng = Province::search('Jawa Tengah')->first();
$jateng = Province::search('33')->first();

// Get related data
$regencies = $jateng->regencies;
$districts = $jateng->districts;
$villages = $jateng->villages;