Fix aircraft retrieval for Simbrief (#1089)
* Fix full aircraft retrieval for simbriefs * F off StyleCIpull/1090/head
parent
11824c9f8b
commit
1287766a46
File diff suppressed because one or more lines are too long
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Http\Resources\SimBrief as SimbriefResource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Flight
|
||||
*/
|
||||
class BidFlight extends Flight
|
||||
{
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$res = parent::toArray($request);
|
||||
|
||||
if ($this->whenLoaded('simbrief')) {
|
||||
unset($res['subfleets']);
|
||||
$res['simbrief'] = new SimbriefResource($this->simbrief);
|
||||
} else {
|
||||
unset($res['simbrief']);
|
||||
$res['subfleets'] = Subfleet::collection($this->whenLoaded('subfleets'));
|
||||
}
|
||||
|
||||
$res['fields'] = $this->setFields();
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
class BidSubfleet extends Subfleet
|
||||
{
|
||||
protected $aircraft;
|
||||
protected $fares;
|
||||
|
||||
public function __construct($resource, $aircraft, $fares)
|
||||
{
|
||||
parent::__construct($resource);
|
||||
|
||||
$this->aircraft = $aircraft;
|
||||
$this->fares = $fares;
|
||||
}
|
||||
|
||||
public function toArray($request)
|
||||
{
|
||||
$res = [];
|
||||
$res['airline_id'] = $this->airline_id;
|
||||
$res['hub_id'] = $this->hub_id;
|
||||
$res['type'] = $this->type;
|
||||
$res['simbrief_type'] = $this->simbrief_type;
|
||||
$res['name'] = $this->name;
|
||||
$res['fuel_type'] = $this->fuel_type;
|
||||
$res['cost_block_hour'] = $this->cost_block_hour;
|
||||
$res['cost_delay_minute'] = $this->cost_delay_minute;
|
||||
$res['ground_handling_multiplier'] = $this->ground_handling_multiplier;
|
||||
$res['cargo_capacity'] = $this->cargo_capacity;
|
||||
$res['fuel_capacity'] = $this->fuel_capacity;
|
||||
$res['gross_weight'] = $this->gross_weight;
|
||||
|
||||
$res['fares'] = Fare::collection($this->fares);
|
||||
|
||||
// There should only be one aircraft tied to a bid subfleet, wrap in a collection
|
||||
$res['aircraft'] = Aircraft::collection([$this->aircraft]);
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue