From 43201a70e6353d47a5302a66c418d1ce1a444a26 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 23 Feb 2021 00:31:12 -0700 Subject: [PATCH] Update user admin, fix pagination --- app/Http/Controllers/Admin/AdminUserController.php | 6 +++--- resources/views/admin/users/home.blade.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Admin/AdminUserController.php b/app/Http/Controllers/Admin/AdminUserController.php index fd16aaa2..4695d699 100644 --- a/app/Http/Controllers/Admin/AdminUserController.php +++ b/app/Http/Controllers/Admin/AdminUserController.php @@ -19,9 +19,9 @@ trait AdminUserController $search = $request->has('a') && $request->query('a') == 'search' ? $request->query('q') : null; $col = $request->query('col') ?? 'id'; $dir = $request->query('dir') ?? 'desc'; - $offset = $request->has('page') ? $request->input('page') : 1; + $offset = $request->has('page') ? $request->input('page') : 0; $pagination = [ - 'prev' => $offset && $offset > 1 ? $offset - 1 : null, + 'prev' => $offset > 0 ? $offset - 1 : null, 'next' => $offset + 1, 'query' => $search ? '&a=search&q=' . $search : null ]; @@ -30,7 +30,7 @@ trait AdminUserController ->when($search, function($q, $search) { return $q->where('username', 'like', "%{$search}%"); }) - ->when($offset > 1, function($q, $offset) { + ->when($offset, function($q, $offset) { return $q->offset(($offset * 10)); }) ->limit(10) diff --git a/resources/views/admin/users/home.blade.php b/resources/views/admin/users/home.blade.php index 47934dbe..973d4536 100644 --- a/resources/views/admin/users/home.blade.php +++ b/resources/views/admin/users/home.blade.php @@ -85,7 +85,7 @@