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;

$province = Province::search(33)->first();

// or

$province = Province::search('Jawa Tengah')->first();

// Retrieve distict list of postal codes available in the province
$province->postal_codes;

use Creasi\Nusa\Contracts\HasAddresses;
use Creasi\Nusa\Models\Concerns\WithAddresses;

class User extends Model implements HasAddresses
{
    use WithAddresses;
}

   // config/nusa.php
   return [
       'connection' => 'indonesia',
   ];
   

   // config/database.php
   return [
       'connections' => [
           'indonesia' => [
               // ...
           ]
       ],
   ];
   
sh
php artisan vendor:publish --tag creasi-migrations