refactor: count on the query, not collection
This commit introduces a short performance boost by counting the records in the query itself, instead of doing that in the collection Laravel returns. Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
@@ -76,7 +76,7 @@ class UserController extends Controller
|
||||
->with([
|
||||
'users' => User::with('roles')->paginate('6'),
|
||||
'numUsers' => count(User::all()),
|
||||
'bannedUserCount' => Ban::all()->count(),
|
||||
'bannedUserCount' => Ban::count(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class UserController extends Controller
|
||||
->with([
|
||||
'users' => $matchingUsers,
|
||||
'numUsers' => count(User::all()),
|
||||
'bannedUserCount' => Ban::all()->count(),
|
||||
'bannedUserCount' => Ban::count(),
|
||||
]);
|
||||
} else {
|
||||
$request->session()->flash('error', __('Your search term did not return any results.'));
|
||||
|
Reference in New Issue
Block a user