mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Added query scope for ordering by admin
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
6ec3693030
commit
a1ce9b9285
|
@ -83,11 +83,19 @@ class ReportsController extends Controller
|
||||||
$offset = ($request->input('offset') > $total) ? $total : app('api_offset_value');
|
$offset = ($request->input('offset') > $total) ? $total : app('api_offset_value');
|
||||||
$limit = app('api_limit_value');
|
$limit = app('api_limit_value');
|
||||||
|
|
||||||
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
|
||||||
$order = ($request->input('order') == 'asc') ? 'asc' : 'desc';
|
$order = ($request->input('order') == 'asc') ? 'asc' : 'desc';
|
||||||
|
|
||||||
|
switch ($request->input('sort')) {
|
||||||
|
case 'admin':
|
||||||
|
$actionlogs->OrderAdmin($order);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||||
|
$actionlogs = $actionlogs->orderBy($sort, $order);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$actionlogs = $actionlogs->orderBy($sort, $order)->skip($offset)->take($limit)->get();
|
$actionlogs = $actionlogs->skip($offset)->take($limit)->get();
|
||||||
|
|
||||||
return response()->json((new ActionlogsTransformer)->transformActionlogs($actionlogs, $total), 200, ['Content-Type' => 'application/json;charset=utf8'], JSON_UNESCAPED_UNICODE);
|
return response()->json((new ActionlogsTransformer)->transformActionlogs($actionlogs, $total), 200, ['Content-Type' => 'application/json;charset=utf8'], JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue