(API) Delete the PIREP route before it's posted again

This commit is contained in:
Nabeel Shahzad 2018-07-05 14:07:54 -05:00
parent 59b99497a7
commit 7c414e5419
2 changed files with 8 additions and 1 deletions

View File

@ -497,6 +497,12 @@ class PirepController extends Controller
Log::info('Posting ROUTE, PIREP: '.$id, $request->post()); 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; $count = 0;
$route = $request->post('route', []); $route = $request->post('route', []);
foreach ($route as $position) { foreach ($route as $position) {

View File

@ -95,6 +95,8 @@ class PirepService extends Service
/** /**
* Save the route into the ACARS table with AcarsType::ROUTE * 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 * @param Pirep $pirep
* @return Pirep * @return Pirep
* @throws \Exception * @throws \Exception
@ -114,7 +116,6 @@ class PirepService extends Service
if (!filled($pirep->dpt_airport)) { if (!filled($pirep->dpt_airport)) {
Log::error('saveRoute: dpt_airport not found: '.$pirep->dpt_airport_id); Log::error('saveRoute: dpt_airport not found: '.$pirep->dpt_airport_id);
return $pirep; return $pirep;
} }