'integer', 'mtow' => 'float', 'zfw' => 'float', 'flight_time' => 'float', 'state' => 'integer', ]; /** * Validation rules */ public static $rules = [ 'subfleet_id' => 'required', 'name' => 'required', 'status' => 'required', 'registration' => 'required', 'mtow' => 'nullable|numeric', 'zfw' => 'nullable|numeric', ]; /** * @return string */ public function getIdentAttribute(): string { return $this->registration.' ('.$this->icao.')'; } /** * See if this aircraft is active * * @return bool */ public function getActiveAttribute(): bool { return $this->status === AircraftStatus::ACTIVE; } /** * Capitalize the ICAO when set * * @param $icao */ public function setIcaoAttribute($icao): void { $this->attributes['icao'] = strtoupper($icao); } /** * Return the landing time in carbon format if provided * * @return Carbon|null */ public function getLandingTimeAttribute() { if (array_key_exists('landing_time', $this->attributes) && filled($this->attributes['landing_time'])) { return new Carbon($this->attributes['landing_time']); } } /** * foreign keys */ public function airline() { return $this->belongsToThrough(Airline::class, Subfleet::class); } public function airport() { return $this->belongsTo(Airport::class, 'airport_id'); } public function pireps() { return $this->hasMany(Pirep::class, 'aircraft_id'); } public function subfleet() { return $this->belongsTo(Subfleet::class, 'subfleet_id'); } }