'int', 'total_time' => 'int', 'active' => 'boolean', ]; /** * Validation rules * * @var array */ public static $rules = [ 'country' => 'nullable', 'iata' => 'nullable|max:5', 'icao' => 'required|max:5', 'logo' => 'nullable', 'name' => 'required', ]; /** * For backwards compatibility */ public function code(): Attribute { return Attribute::make( get: function ($_, $attrs) { if ($this->iata && $this->iata !== '') { return $this->iata; } return $this->icao; } ); } /** * Capitalize the IATA code when set */ public function iata(): Attribute { return Attribute::make( set: fn ($iata) => Str::upper($iata) ); } /** * Capitalize the ICAO when set */ public function icao(): Attribute { return Attribute::make( set: fn ($icao) => Str::upper($icao) ); } /* * FKs */ public function subfleets() { return $this->hasMany(Subfleet::class, 'airline_id'); } public function aircraft() { return $this->hasManyThrough(Aircraft::class, Subfleet::class); } public function flights() { return $this->belongsTo(Flight::class, 'airline_id'); } public function pireps() { return $this->belongsTo(Pirep::class, 'airline_id'); } }