Posts Learn Components new Snippets new Categories Tags About Device Beast sponsor

How to Get Current Pagination Data in Laravel

Learn how to get the current page items in Laravel pagination

Created on Jul 01, 2021


To get the current pagination page data/items in Laravel you can chain the "items" method after the "paginate" method.
$posts = Post::query()
    ->items(); // only get the data

By accessing the pagination data like above you will be able to loop through the arrays in your views.
@foreach($posts as $post)
        <h1>{{ $post->title }}</h1>
        <p>{{ $post->subtitle }}</p>

Snippets by

PostSrc poster


Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

Load comments for How to Get Current Pagination Data in Laravel


PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components

Other Code Snippets