M
M
maks789452021-01-08 14:44:07
Laravel
maks78945, 2021-01-08 14:44:07

How to implement paginate to multiple pages in laravel?

I use "paginate" but I get "« Previous Next »" in the documentation, I found that I need to use the paginate instance of the "Illuminate\Pagination\LengthAwarePaginator" class instance to list pages, but I can not find an example of how to do this. Larvel 8

Here is the controller code

public function index()
    {
        $field = [
            'id',
            'name',
            'email',
            'created_at'
        ];

        $userQuery = User::select($field);
        $userQuery = $this->userService->filter($userQuery);
        $userQuery = $this->userService->sort($userQuery);

        $users = $userQuery->paginate(2);


        return view('admin.user.index', compact('users'));
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2021-01-08
@maks78945

You already have a LengthAwarePaginator. So it's the pagination template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question