1. Go to this page and download the library: Download raiolanetworks/atlas 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/ */
raiolanetworks / atlas example snippets
use Raiolanetworks\Atlas\Models\Country;
class MyClass
{
public function getAllAfricaCountries(): Collection
{
return Country::where('region_name', 'Africa')
->orderBy('name')
->get();
}
}
use Raiolanetworks\Atlas\Models\State;
// Get only top-level divisions (e.g., Autonomous Communities in Spain)
State::where('country_code', 'ES')->topLevel()->get();
// Get subdivisions of a specific state
$catalonia = State::where('state_code', 'CT')->first();
$catalonia->children; // Provinces: Barcelona, Girona, Lleida, Tarragona
// Navigate up the hierarchy
$barcelona = State::where('name', 'Barcelona')->first();
$barcelona->parent; // Cataluña