diff --git a/app/Http/Controllers/Api/PirepController.php b/app/Http/Controllers/Api/PirepController.php index 95777f60..06765e42 100644 --- a/app/Http/Controllers/Api/PirepController.php +++ b/app/Http/Controllers/Api/PirepController.php @@ -497,6 +497,12 @@ class PirepController extends Controller Log::info('Posting ROUTE, PIREP: '.$id, $request->post()); + // Delete the route before posting a new one + Acars::where([ + 'pirep_id' => $id, + 'type' => AcarsType::ROUTE + ])->delete(); + $count = 0; $route = $request->post('route', []); foreach ($route as $position) { diff --git a/app/Services/PirepService.php b/app/Services/PirepService.php index 680bd4c7..31c7431a 100644 --- a/app/Services/PirepService.php +++ b/app/Services/PirepService.php @@ -95,6 +95,8 @@ class PirepService extends Service /** * Save the route into the ACARS table with AcarsType::ROUTE + * This attempts to create the route from the navdata and the route + * entered into the PIREP's route field * @param Pirep $pirep * @return Pirep * @throws \Exception @@ -114,7 +116,6 @@ class PirepService extends Service if (!filled($pirep->dpt_airport)) { Log::error('saveRoute: dpt_airport not found: '.$pirep->dpt_airport_id); - return $pirep; }