1
0
Fork 0
forked from mirror/pixelfed

Merge pull request #2682 from pixelfed/staging

Update user admin, fix pagination
This commit is contained in:
daniel 2021-02-23 00:32:47 -07:00 committed by GitHub
commit 390c083d12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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>