laravel-aircrafts maintained by flairuk
Description
IATA aircraft type codes for Laravel: an in-memory lookup API, validation rule and optional database table.
Author
Last update
2026/10/05 13:03
(dev-main)
License
Downloads
101
Laravel Aircrafts — IATA aircraft type designators (320, 738, 388, …) for Laravel 12 and 13.
- No database required. Look aircraft types up through a facade backed by an in-memory dataset.
- Typed results. Every lookup returns readonly
Aircraftobjects in Laravel collections keyed by code. - Validation rule.
new AircraftCodeaccepts known codes only. - Optional table. Publish a migration and seed an
aircraftstable.
📦 Installation
composer require flairuk/laravel-aircrafts
Requires PHP 8.2 or later with Laravel 12, or PHP 8.3 or later with Laravel 13.
Laravel discovers the service provider and the Aircrafts facade automatically.
🚀 Usage
use FLAIRUK\Aircrafts\Facades\Aircrafts;
Aircrafts::find('738'); // Aircraft { id: 55, code: "738", name: "Boeing 737-800" }
Aircrafts::findOrFail('388'); // throws ItemNotFoundException for unknown codes
Aircrafts::exists('73h'); // true (codes are case-insensitive)
Aircrafts::findById(55);
Aircrafts::all(); // Collection<string, Aircraft> keyed by code
Aircrafts::search('a380'); // matches on name or exact code
Aircrafts::codes();
Select options
Aircrafts::options(); // ['738' => 'Boeing 737-800', ...] sorted by name
Validation
use FLAIRUK\Aircrafts\Rules\AircraftCode;
$request->validate(['equipment' => ['required', new AircraftCode]]);
💾 Database table (optional)
php artisan aircrafts:install # publish config + migration, then ask to migrate and seed
php artisan aircrafts:install --migrate # migrate and seed without asking
php artisan aircrafts:seed # insert / update (safe to re-run)
php artisan aircrafts:seed --prune # also delete rows no longer in the dataset
You can also call the seeder from your own DatabaseSeeder:
$this->call(\FLAIRUK\Aircrafts\Database\AircraftsSeeder::class);
The bundled FLAIRUK\Aircrafts\Models\Aircraft model gives you Aircraft::code('738')->first(). The table name and connection come from AIRCRAFTS_TABLE and AIRCRAFTS_DB_CONNECTION, or from the published config.
🔄 Upgrading from dev-master
Version 1.0 is a rewrite. Breaking changes:
| dev-master | 1.0 |
|---|---|
Package ijeffro/laravel-aircrafts |
flairuk/laravel-aircrafts |
ijeffro\Aircrafts\… namespace |
FLAIRUK\Aircrafts\… |
Facade ijeffro\Aircrafts\AircraftsFacade |
FLAIRUK\Aircrafts\Facades\Aircrafts (auto-discovered) |
Aircrafts::getList($sort) (array) |
Aircrafts::all()->sortBy($property, SORT_NATURAL | SORT_FLAG_CASE) (Collection of Aircraft) |
Aircrafts::getOne($id) |
Aircrafts::findById($id) or Aircrafts::find($code) |
Aircrafts::getListForSelect() (keyed by id) |
Aircrafts::options('id') |
php artisan aircrafts:migration |
php artisan aircrafts:install / aircrafts:seed |
Config key aircrafts.table_name |
aircrafts.table |
updated field (a 2015 import timestamp) |
removed |
Row ids are unchanged.
🧪 Testing
composer test
📄 License
MIT. See LICENSE.