Remove SimBrief with Bid (#1283)

* Update BidService.php

* Update BidService.php

Delete directly ;)
This commit is contained in:
B.Fatih KOZ 2021-08-13 21:39:18 +03:00 committed by GitHub
parent d64e674c21
commit b0f52ed1d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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