Fix aircraft retrieval for Simbrief (#1089)

* Fix full aircraft retrieval for simbriefs

* F off StyleCI
This commit is contained in:
Nabeel S
2021-03-19 18:25:19 -04:00
committed by GitHub
parent 11824c9f8b
commit 1287766a46
10 changed files with 116 additions and 21 deletions

View File

@@ -12,27 +12,27 @@ class SimBrief extends Resource
public function toArray($request)
{
$data = [
'id' => $this->id,
'url' => url(route('api.flights.briefing', ['id' => $this->id])),
'id' => $this->id,
'aircraft_id' => $this->aircraft_id,
'url' => url(route('api.flights.briefing', ['id' => $this->id])),
];
$fares = [];
try {
if (!empty($this->fare_data)) {
$fares = [];
$fare_data = json_decode($this->fare_data, true);
foreach ($fare_data as $fare) {
$fares[] = new \App\Models\Fare($fare);
}
$this->aircraft->subfleet->fares = collect($fares);
$fares = collect($fares);
}
} catch (\Exception $e) {
// Invalid fare data
}
if ($this->aircraft->subfleet) {
$data['subfleet'] = new Subfleet($this->aircraft->subfleet);
}
$data['subfleet'] = new BidSubfleet($this->aircraft->subfleet, $this->aircraft, $fares);
return $data;
}