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) {