Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

laravel
php
pagination
communitycreator

How to display a paginated result in Laravel

Chinweuba Elijah Azubuike

In a previous shot, we discussed paginating the result from an Eloquent query. Now we will display those results to our frontend.

How to display a paginated result in Laravel

widget

The image above shows how the links for the pagination will look if you do it correctly. It might not be up to five, depending on the content from your database.

The paginate() method can be iterated like an array and this result can be displayed in the Blade like so:

<div class="container">
    @foreach ($users as $user)
        {{ $user->name }}
    @endforeach
</div>

{{ $users->links() }}

The links() method will automatically appear on all the pages.

The HTML generated by the links() method is dependent on the Tailwind CSS framework.

RELATED TAGS

laravel
php
pagination
communitycreator

CONTRIBUTOR

Chinweuba Elijah Azubuike
RELATED COURSES

View all Courses

Keep Exploring