Add setting to automatically remove bid on PIREP accept #200

This commit is contained in:
Nabeel Shahzad
2018-03-15 18:20:07 -05:00
parent 58fbbd98a4
commit ccbc109db2
7 changed files with 120 additions and 39 deletions

View File

@@ -23,6 +23,8 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property Airport dep_airport
* @property integer flight_time In minutes
* @property User user
* @property Flight|null flight
* @property int user_id
* @package App\Models
*/
class Pirep extends BaseModel
@@ -190,6 +192,29 @@ class Pirep extends BaseModel
}
}
/**
* Look up the flight, based on the PIREP flight info
* @return Flight|null
*/
public function getFlightAttribute()
{
$where = [
'airline_id' => $this->airline_id,
'flight_number' => $this->flight_number,
'active' => true,
];
if (filled($this->route_code)) {
$where['route_code'] = $this->route_code;
}
if (filled($this->route_leg)) {
$where['route_leg'] = $this->route_leg;
}
return Flight::where($where)->first();
}
/**
* Set the amount of fuel used
* @param $value