From eeabb8c979e034ff497f112966ffdd2246f8b8f2 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 20 Feb 2023 21:15:13 +0000 Subject: [PATCH] Apply fixes from StyleCI --- .../Controllers/LaravelLoggerController.php | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/App/Http/Controllers/LaravelLoggerController.php b/src/App/Http/Controllers/LaravelLoggerController.php index 9ce6c58..36fb5d2 100644 --- a/src/App/Http/Controllers/LaravelLoggerController.php +++ b/src/App/Http/Controllers/LaravelLoggerController.php @@ -86,13 +86,12 @@ public function showAccessLog(Request $request) self::mapAdditionalDetails($activities); - - if(config('LaravelLogger.enableLiveSearch')){ - // We are querying only the paginated userIds because in a big application querying all user data is performance heavy - $user_ids = array_unique($activities->pluck('userId')->toArray()); - $users = config('LaravelLogger.defaultUserModel')::whereIn(config('LaravelLogger.defaultUserIDField'), $user_ids)->get(); - }else{ - $users = config('LaravelLogger.defaultUserModel')::all(); + if (config('LaravelLogger.enableLiveSearch')) { + // We are querying only the paginated userIds because in a big application querying all user data is performance heavy + $user_ids = array_unique($activities->pluck('userId')->toArray()); + $users = config('LaravelLogger.defaultUserModel')::whereIn(config('LaravelLogger.defaultUserIDField'), $user_ids)->get(); + } else { + $users = config('LaravelLogger.defaultUserModel')::all(); } $data = [ @@ -312,22 +311,23 @@ public function searchActivityLog($query, $request) } return $query; - } - /** - * Search the database users according to specific criteria. - * - * @param request - * - * @return filtered user data - */ - public function liveSearch(Request $request){ - - $filteredUsers = config('LaravelLogger.defaultUserModel')::when(request('userid'), function ($q) { - return $q->where(config('LaravelLogger.defaultUserIDField'), (int) request('userid', 0)); - })->when(request('email'), function ($q) { - return $q->where('email', 'like', '%' . request('email') . '%'); - }); - - return response()->json($filteredUsers->get()->pluck('email', config('LaravelLogger.defaultUserIDField')), 200); - } + } + + /** + * Search the database users according to specific criteria. + * + * @param request + * + * @return filtered user data + */ + public function liveSearch(Request $request) + { + $filteredUsers = config('LaravelLogger.defaultUserModel')::when(request('userid'), function ($q) { + return $q->where(config('LaravelLogger.defaultUserIDField'), (int) request('userid', 0)); + })->when(request('email'), function ($q) { + return $q->where('email', 'like', '%'.request('email').'%'); + }); + + return response()->json($filteredUsers->get()->pluck('email', config('LaravelLogger.defaultUserIDField')), 200); + } }