Fixes API sorting and filtering. Closes #1489

This commit is contained in:
Joseph Cohen
2016-02-23 13:34:22 -06:00
committed by James Brooks
parent 98550c31c9
commit 919c7127e7
10 changed files with 136 additions and 14 deletions
@@ -32,7 +32,15 @@ class IncidentController extends AbstractApiController
{
$incidentVisibility = app(Guard::class)->check() ? 0 : 1;
$incidents = Incident::where('visible', '>=', $incidentVisibility)->paginate(Binput::get('per_page', 20));
$incidents = Incident::where('visible', '>=', $incidentVisibility);
if ($sortBy = Binput::get('sort')) {
$direction = Binput::has('order') && Binput::get('order') == 'desc';
$incidents->sort($sortBy, $direction);
}
$incidents = $incidents->paginate(Binput::get('per_page', 20));
return $this->paginator($incidents, Request::instance());
}