From b0f52ed1d0e92e4affed9ae1e045f080e87c2d53 Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Fri, 13 Aug 2021 21:39:18 +0300 Subject: [PATCH] Remove SimBrief with Bid (#1283) * Update BidService.php * Update BidService.php Delete directly ;) --- app/Services/BidService.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Services/BidService.php b/app/Services/BidService.php index 6a0d8047..5b015bc2 100644 --- a/app/Services/BidService.php +++ b/app/Services/BidService.php @@ -8,6 +8,7 @@ use App\Exceptions\UserBidLimit; use App\Models\Bid; use App\Models\Flight; use App\Models\Pirep; +use App\Models\SimBrief; use App\Models\User; use Illuminate\Support\Facades\Log; @@ -164,6 +165,14 @@ class BidService extends Service $bid->forceDelete(); } + // Remove SimBrief OFP when removing the bid if it is not flown + if (setting('simbrief.only_bids')) { + $simbrief = SimBrief::where([ + 'user_id' => $user->id, + 'flight_id' => $flight->id, + ])->whereNull('pirep_id')->delete(); + } + // Only flip the flag if there are no bids left for this flight $bid_count = Bid::where(['flight_id' => $flight->id])->count(); if ($bid_count === 0) {