diff --git a/app/Models/Flight.php b/app/Models/Flight.php index ea55bd06..67282772 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -9,10 +9,11 @@ use PhpUnitsOfMeasure\Exception\NonNumericValue; use PhpUnitsOfMeasure\Exception\NonStringUnitName; /** - * @property Airline airline - * @property mixed flight_number - * @property mixed route_code - * @property mixed route_leg + * @property Airline airline + * @property mixed flight_number + * @property mixed route_code + * @property mixed route_leg + * @property FlightFields[] fields */ class Flight extends Model { @@ -121,6 +122,21 @@ class Flight extends Model } } + /** + * Return a custom field value + * @param $field_name + * @return string + */ + public function field($field_name) + { + $field = $this->fields->where('name', $field_name)->first(); + if($field) { + return $field['value']; + } + + return ''; + } + /** * Relationship */