Skip to content

Commit

Permalink
Get the correct ordering for flight route on map
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Feb 21, 2018
1 parent ec9d00c commit 7705599
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Models/Pirep.php
Expand Up @@ -240,7 +240,7 @@ public function acars()
{ {
return $this->hasMany(Acars::class, 'pirep_id') return $this->hasMany(Acars::class, 'pirep_id')
->where('type', AcarsType::FLIGHT_PATH) ->where('type', AcarsType::FLIGHT_PATH)
->orderBy('created_at', 'asc'); ->orderBy('created_at', 'desc');
} }


public function acars_logs() public function acars_logs()
Expand Down
14 changes: 10 additions & 4 deletions app/Repositories/AcarsRepository.php
Expand Up @@ -28,12 +28,18 @@ public function forPirep($pirep_id, $type)
'type' => $type, 'type' => $type,
]; ];


$order_by = 'created_at'; switch($type) {
if($type === AcarsType::ROUTE) { default:
$order_by = 'order'; case AcarsType::FLIGHT_PATH:
case AcarsType::LOG:
$order_by = 'created_at';
break;
case AcarsType::ROUTE:
$order_by = 'order';
break;
} }


return $this->orderBy('order', 'asc')->findWhere($where); return $this->orderBy($order_by, 'asc')->findWhere($where);
} }


/** /**
Expand Down

0 comments on commit 7705599

Please sign in to comment.