Block refiling of PIREPs (#1167)

* Block refiling of PIREPs

* Style fixes

* Package updates
This commit is contained in:
Nabeel S
2021-05-03 10:00:10 -04:00
committed by GitHub
parent 5094375e13
commit fe0ef60b6c
7 changed files with 518 additions and 383 deletions

View File

@@ -14,6 +14,7 @@ use App\Exceptions\AircraftNotAtAirport;
use App\Exceptions\AircraftPermissionDenied;
use App\Exceptions\AirportNotFound;
use App\Exceptions\PirepCancelNotAllowed;
use App\Exceptions\PirepError;
use App\Exceptions\UserNotAtAirport;
use App\Models\Acars;
use App\Models\Aircraft;
@@ -231,6 +232,18 @@ class PirepService extends Service
$field_values = [];
}
// Check if the PIREP has already been submitted
$is_already_submitted = in_array($pirep->state, [
PirepState::PENDING,
PirepState::ACCEPTED,
PirepState::CANCELLED,
PirepState::REJECTED,
], true);
if ($is_already_submitted) {
throw new PirepError($pirep, 'PIREP has already been submitted');
}
$attrs['state'] = PirepState::PENDING;
$attrs['status'] = PirepStatus::ARRIVED;
$attrs['submitted_at'] = Carbon::now('UTC');