-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix aircraft retrieval for Simbrief (#1089)
* Fix full aircraft retrieval for simbriefs * F off StyleCI
- Loading branch information
Showing
10 changed files
with
116 additions
and
21 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters