From f8a21bdb2dfbe6985d97c5cad369be2f6bf033b6 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 5 Jan 2024 11:59:31 +0000 Subject: [PATCH] Moved limit and offset to after additional qualifiers Signed-off-by: snipe --- app/Http/Controllers/Api/UsersController.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 671c8aafee..3eb7783e3d 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -192,11 +192,6 @@ class UsersController extends Controller $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')) { case 'manager': $users = $users->OrderManager($order); @@ -273,7 +268,17 @@ class UsersController extends Controller } $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(); $users = $users->skip($offset)->take($limit)->get();