Fixes API sorting and filtering. Closes #1489
This commit is contained in:
committed by
James Brooks
parent
98550c31c9
commit
919c7127e7
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user