PHP code example of raiolanetworks / atlas

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

State::where('country_code', 'BY')->topLevel()->get()
    ->map(fn (State $s) => "{$s->name} ({$s->type})"); // "Minsk (oblast)", "Minsk (city)"
bash
php artisan vendor:publish --tag="atlas-config"
bash
php artisan atlas:install
bash
php artisan atlas:update
bash
php artisan vendor:publish --tag="atlas-translations"
php artisan vendor:publish --tag="atlas-jsons"        # JSON data files (for overriding)