Refactoring Simbrief fares and aircraft (#1054)
* Refactoring simbrief fares and aircraft * Hide user full name/email * Sort PIREP fields desc; fix cargo counts * Change the sorting * Extra logs * Fix tests * Return fare information through the API * Style fixes * Test fix * Another test fix * More fixes * Set aircraft and fares in prefile * Formatting
This commit is contained in:
@@ -11,9 +11,27 @@ class SimBrief extends Resource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
$data = [
|
||||
'id' => $this->id,
|
||||
'url' => url(route('api.flights.briefing', ['id' => $this->id])),
|
||||
];
|
||||
|
||||
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);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Invalid fare data
|
||||
}
|
||||
|
||||
$data['subfleet'] = new Subfleet($this->aircraft->subfleet);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user