'float', 'lon' => 'float', 'hub' => 'boolean', 'ground_handling_cost' => 'float', 'fuel_100ll_cost' => 'float', 'fuel_jeta_cost' => 'float', 'fuel_mogas_cost' => 'float', ]; /** * Validation rules */ public static $rules = [ 'icao' => 'required', 'iata' => 'sometimes|nullable', 'name' => 'required', 'location' => 'sometimes', 'lat' => 'required|numeric', 'lon' => 'required|numeric', 'ground_handling_cost' => 'nullable|numeric', 'fuel_100ll_cost' => 'nullable|numeric', 'fuel_jeta_cost' => 'nullable|numeric', 'fuel_mogas_cost' => 'nullable|numeric', ]; /** * Capitalize the ICAO */ public function icao(): Attribute { return Attribute::make( set: fn ($icao) => [ 'id' => strtoupper($icao), 'icao' => strtoupper($icao), ] ); } /** * Capitalize the IATA code */ public function iata(): Attribute { return Attribute::make( set: fn ($iata) => strtoupper($iata) ); } /** * Return full name like: * KJFK - John F Kennedy * * @return string */ public function fullName(): Attribute { return Attribute::make( get: fn ($_, $attrs) => $this->icao.' - '.$this->name ); } /** * Shortcut for timezone * * @return Attribute */ public function tz(): Attribute { return Attribute::make( get: fn ($_, $attrs) => $attrs['timezone'], set: fn ($value) => [ 'timezone' => $value, ] ); } }