Laravel - Pagination - Displaying Pagination Results
When calling the paginate
method, you will receive an instance of Illuminate\Pagination\LengthAwarePaginator
, while calling the simplePaginate
method returns an instance of Illuminate\Pagination\Paginator
. And, finally, calling the cursorPaginate
method returns an instance of Illuminate\Pagination\CursorPaginator
.
These objects provide several methods that describe the result set. In addition to these helpers methods, the paginator instances are iterators and may be looped as an array. So, once you have retrieved the results, you may display the results and render the page links using Blade:
@foreach ($users as $user)
{{ $user->name }}
@endforeach
{{ $users->links() }}
The links
method will render the links to the rest of the pages in the result set. Each of these links will already contain the proper page
query string variable. Remember, the HTML generated by the links
method is compatible with the Tailwind CSS framework.