Implement simple pagination

This commit is contained in:
Ahmed Ashraf
2020-06-26 12:20:01 +02:00
parent baa9819daf
commit e960ffb825
5 changed files with 74 additions and 7 deletions

View File

@@ -21,10 +21,10 @@ class GetUsersController extends AdminController
public function handle(Request $request, ConnectionInterface $httpConnection)
{
$this->userRepository
->getUsers()
->then(function ($users) use ($httpConnection) {
->paginateUsers(20, (int) $request->get('page', 1))
->then(function ($paginated) use ($httpConnection) {
$httpConnection->send(
respond_json(['users' => $users])
respond_json(['paginated' => $paginated])
);
$httpConnection->close();

View File

@@ -21,10 +21,10 @@ class ListUsersController extends AdminController
public function handle(Request $request, ConnectionInterface $httpConnection)
{
$this->userRepository
->getUsers()
->then(function ($users) use ($httpConnection) {
->paginateUsers(20, (int) $request->get('page', 1))
->then(function ($paginated) use ($httpConnection) {
$httpConnection->send(
respond_html($this->getView($httpConnection, 'server.users.index', ['users' => $users]))
respond_html($this->getView($httpConnection, 'server.users.index', ['paginated' => $paginated]))
);
$httpConnection->close();