Add a helper method in the Flight model to more easily get a custom value
This commit is contained in:
@@ -9,10 +9,11 @@ use PhpUnitsOfMeasure\Exception\NonNumericValue;
|
|||||||
use PhpUnitsOfMeasure\Exception\NonStringUnitName;
|
use PhpUnitsOfMeasure\Exception\NonStringUnitName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Airline airline
|
* @property Airline airline
|
||||||
* @property mixed flight_number
|
* @property mixed flight_number
|
||||||
* @property mixed route_code
|
* @property mixed route_code
|
||||||
* @property mixed route_leg
|
* @property mixed route_leg
|
||||||
|
* @property FlightFields[] fields
|
||||||
*/
|
*/
|
||||||
class Flight extends Model
|
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
|
* Relationship
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user