mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Merge pull request #14103 from snipe/bug/user_api_limit_offset_order
Moved limit and offset in user API to after additional qualifiers
This commit is contained in:
commit
93712ec417
|
@ -192,11 +192,6 @@ class UsersController extends Controller
|
||||||
|
|
||||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||||
|
|
||||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
|
||||||
$offset = ($request->input('offset') > $users->count()) ? $users->count() : app('api_offset_value');
|
|
||||||
$limit = app('api_limit_value');
|
|
||||||
|
|
||||||
|
|
||||||
switch ($request->input('sort')) {
|
switch ($request->input('sort')) {
|
||||||
case 'manager':
|
case 'manager':
|
||||||
$users = $users->OrderManager($order);
|
$users = $users->OrderManager($order);
|
||||||
|
@ -274,6 +269,16 @@ class UsersController extends Controller
|
||||||
|
|
||||||
$users = Company::scopeCompanyables($users);
|
$users = Company::scopeCompanyables($users);
|
||||||
|
|
||||||
|
|
||||||
|
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||||
|
$offset = ($request->input('offset') > $users->count()) ? $users->count() : app('api_offset_value');
|
||||||
|
$limit = app('api_limit_value');
|
||||||
|
|
||||||
|
\Log::debug('Requested offset: '. $request->input('offset'));
|
||||||
|
\Log::debug('App offset: '. app('api_offset_value'));
|
||||||
|
\Log::debug('Actual offset: '. $offset);
|
||||||
|
\Log::debug('Limit: '. $limit);
|
||||||
|
|
||||||
$total = $users->count();
|
$total = $users->count();
|
||||||
$users = $users->skip($offset)->take($limit)->get();
|
$users = $users->skip($offset)->take($limit)->get();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue