1
0
Fork 0

Update user admin, fix pagination

This commit is contained in:
Daniel Supernault 2021-02-23 00:31:12 -07:00
parent 53042d295e
commit 43201a70e6
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
2 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -85,7 +85,7 @@
</div>
<div class="d-flex justify-content-center mt-5 small">
<ul class="pagination">
@if($pagination['prev'])
@if($pagination['prev'] !== null || $pagination['prev'] == 1)
<li class="page-item"><a class="page-link pagination__prev" href="?page={{$pagination['prev']}}{{$pagination['query']}}" rel="prev">« Previous</a></li>
@else
<li class="page-item disabled"><span class="page-link" >« Previous</span></li>