Add order column to ACARS table for the order of the route points

This commit is contained in:
Nabeel Shahzad
2018-01-02 09:40:42 -06:00
parent 7a6395be27
commit 37cdde845d
5 changed files with 19 additions and 5 deletions

View File

@@ -62,9 +62,9 @@ class PIREPService extends BaseService
{
# Delete all the existing nav points
Acars::where([
'pirep_id' => $pirep->id,
'type' => AcarsType::ROUTE,
])->delete();
'pirep_id' => $pirep->id,
'type' => AcarsType::ROUTE,
])->delete();
# Delete the route
if (empty($pirep->route)) {
@@ -81,16 +81,19 @@ class PIREPService extends BaseService
/**
* @var $point Navdata
*/
$point_count = 1;
foreach ($route as $point) {
$acars = new Acars();
$acars->pirep_id = $pirep->id;
$acars->type = AcarsType::ROUTE;
$acars->nav_type = $point->type;
$acars->order = $point_count;
$acars->name = $point->id;
$acars->lat = $point->lat;
$acars->lon = $point->lon;
$acars->save();
++$point_count;
}
return $pirep;