diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 67282772..bff915c4 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -5,15 +5,16 @@ namespace App\Models; use App\Interfaces\Model; use App\Models\Traits\HashIdTrait; use App\Support\Units\Distance; +use Illuminate\Support\Collection; use PhpUnitsOfMeasure\Exception\NonNumericValue; use PhpUnitsOfMeasure\Exception\NonStringUnitName; /** - * @property Airline airline - * @property mixed flight_number - * @property mixed route_code - * @property mixed route_leg - * @property FlightFields[] fields + * @property Airline airline + * @property mixed flight_number + * @property mixed route_code + * @property mixed route_leg + * @property Collection fields */ class Flight extends Model { @@ -127,7 +128,7 @@ class Flight extends Model * @param $field_name * @return string */ - public function field($field_name) + public function field($field_name): string { $field = $this->fields->where('name', $field_name)->first(); if($field) { diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php index 28425e93..86c002db 100644 --- a/app/Models/Pirep.php +++ b/app/Models/Pirep.php @@ -8,6 +8,7 @@ use App\Models\Enums\PirepState; use App\Models\Traits\HashIdTrait; use App\Support\Units\Distance; use App\Support\Units\Fuel; +use Illuminate\Support\Collection; use PhpUnitsOfMeasure\Exception\NonNumericValue; use PhpUnitsOfMeasure\Exception\NonStringUnitName; @@ -26,6 +27,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName; * @property integer flight_time In minutes * @property User user * @property Flight|null flight + * @property Collection fields * @package App\Models */ class Pirep extends Model @@ -272,6 +274,21 @@ class Pirep extends Model return true; } + /** + * Return a custom field value + * @param $field_name + * @return string + */ + public function field($field_name): string + { + $field = $this->fields->where('name', $field_name)->first(); + if ($field) { + return $field['value']; + } + + return ''; + } + /** * Foreign Keys */