PHP code example of flairuk / laravel-world

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

    

flairuk / laravel-world example snippets


use FLAIRUK\World\Facades\World;

World::country('GBR');               // Country, or null
World::countryOrFail('GB');          // throws ItemNotFoundException for an unknown code

World::citiesIn('GB');               // Collection of City: LON, MAN, EDI, …
World::airportsIn('GBR');            // Collection of Airport: LHR, LGW, MAN, …
World::airlinesIn(826);              // Collection of Airline: BA, VS, …

$profile = World::profile('GB');     // CountryProfile, or null

$profile->country;                   // Country
$profile->cities;                    // Collection of City
$profile->airports;                  // Collection of Airport
$profile->airlines;                  // Collection of Airline

return $profile;                     // {"country": {...}, "cities": [...], "airports": [...], "airlines": [...]}

World::countryOf(World::airports()->find('LHR'))->name;     // "United Kingdom"
World::countryOf(World::cities()->find('LON'))->name;       // "United Kingdom"
World::countryOf(World::airlines()->find('BA'))->name;      // "United Kingdom"

World::code('LHR');      // ['airport' => Airport]
World::code('LON');      // ['city' => City]
World::code('BA');       // ['country' => Bosnia and Herzegovina, 'airlines' => Collection [British Airways]]
World::code('320');      // ['country' => Guatemala (numeric 320), 'aircraft' => Airbus Industrie A320]

World::search('london');         // ['cities' => [...], 'airports' => [...]]
World::search('london', 3);      // at most three of each

World::countries()->eea();
World::cities()->find('NYC');
World::airports()->search('Heathrow');
World::airlines()->allWithCode('BA');
World::aircraft()->find('388');
bash
php artisan world:install            # asks before migrating
php artisan world:install --migrate  # doesn't ask