PHP code example of uatthaphon / laravel-thai-address

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

    

uatthaphon / laravel-thai-address example snippets


'providers' => [
  ...

  Uatthaphon\ThaiAddress\ThaiAddressServiceProvider::class,
],

use Uatthaphon\ThaiAddress\Models\ThailandProvince;
use Uatthaphon\ThaiAddress\Models\ThailandDistrict;
use Uatthaphon\ThaiAddress\Models\ThailandSubdistrict;

...

/**
 * Available Relationships
 */

// list all districts under the province
app(ThailandProvince::class)->find(1)->districts()->get();

// get province of the district
app(ThailandDistrict::class)->find(1)->province;
// list all sub districtes under the district
app(ThailandDistrict::class)->find(1)->subdistricts()->get();

// get district of the subdistrict
app(ThailandSubdistrict::class)->find(1)->district;
// get province of the subdistrict
app(ThailandSubdistrict::class)->find(1)->province;
bash
php artisan vendor:publish
bash
php artisan migrate
bash
php artisan db:seed --class=ThailandAddressSeeder