PHP code example of ijeffro / laravel-airports

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

    

ijeffro / laravel-airports example snippets


use FLAIRUK\Airports\Facades\Airports;

Airports::find('lhr');           // Airport { id: 4329, code: "LHR", name: "Heathrow", countryCode: "GB" }
Airports::findOrFail('LHR');     // throws ItemNotFoundException for unknown codes
Airports::exists('JFK');         // true
Airports::findById(4329);

Airports::all();                 // Collection<string, Airport> keyed by code
Airports::inCountry('GB');       // airports in the UK
Airports::search('heathrow');    // matches on name or exact code
Airports::codes();               // ['AAA', 'AAB', ...]

Airports::options();             // ['LHR' => 'Heathrow', ...] sorted by name
Airports::options('id');         // [4329 => 'Heathrow', ...]

use FLAIRUK\Airports\Rules\AirportCode;

$request->validate([
    'origin' => ['

$this->call(\FLAIRUK\Airports\Database\AirportsSeeder::class);

use FLAIRUK\Airports\Models\Airport;

Airport::code('LHR')->first();
Airport::inCountry('GB')->orderBy('name')->get();