1. Go to this page and download the library: Download sitehandy/laravel-world 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/ */
use Sitehandy\World\Models\Continent;
$asia = Continent::getByCode('AS');
$countries = $asia->countries()->get();
// or use children method
$countries = $asia->children();
use Sitehandy\World\Models\Country;
$china = Country::getByCode('cn');
$asia = $china->parent(); // Returns the continent
use Sitehandy\World\Models\Country;
$china = Country::getByCode('cn');
$provinces = $china->divisions()->get();
// or use children method
$provinces = $china->children();
use Sitehandy\World\Models\Country;
$china = Country::getByCode('cn');
// Check has_division to determine if next level is division or city
if ($china->has_division) {
$regions = $china->children(); // Returns divisions/provinces
} else {
$cities = $china->children(); // Returns cities directly
}