From 74a1b4d7534b0106f521ca346ee491a51219dde9 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 4 Feb 2022 14:13:40 -0500 Subject: [PATCH] Add subfleet data when single bid is retrieved --- app/Models/Bid.php | 2 ++ app/Services/BidService.php | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Models/Bid.php b/app/Models/Bid.php index 362a07b9..cbe399a6 100644 --- a/app/Models/Bid.php +++ b/app/Models/Bid.php @@ -10,6 +10,8 @@ use Carbon\Carbon; * @property string flight_id * @property Carbon created_at * @property Carbon updated_at + * @property Flight flight + * @property User user */ class Bid extends Model { diff --git a/app/Services/BidService.php b/app/Services/BidService.php index 5b015bc2..847aa482 100644 --- a/app/Services/BidService.php +++ b/app/Services/BidService.php @@ -48,7 +48,15 @@ class BidService extends Service 'flight.subfleets.fares', ]; - return Bid::with($with)->where(['id' => $bid_id])->first(); + /** @var Bid $bid */ + $bid = Bid::with($with)->where(['id' => $bid_id])->first(); + + // Reconcile the aircraft for this bid + // TODO: Only do this if there isn't a Simbrief attached? + $bid->flight = $this->flightSvc->filterSubfleets($user, $bid->flight); + $bid->flight = $this->fareSvc->getReconciledFaresForFlight($bid->flight); + + return $bid; } /**