'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 getCodeAttribute() { if ($this->iata && $this->iata !== '') { return $this->iata; } return $this->icao; } /** * Capitalize the IATA code when set * * @param $iata */ public function setIataAttribute($iata) { $this->attributes['iata'] = Str::upper($iata); } /** * Capitalize the ICAO when set * * @param $icao */ public function setIcaoAttribute($icao): void { $this->attributes['icao'] = Str::upper($icao); } 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'); } }