lundi 18 juillet 2016

Why Laravel Pagination stuck at page 1?

I have a very simple Laravel application. Basically I'm using Eloquent to pull out data from the DB and paginate them.

However it's not working properly. Every time I'm using the paginate command I'm getting the first page's result only.

Here's my code:

$forum = new Forum;
$posts = $forum->paginate(5);
return $posts;

What I'm getting back as JSON is:

total: 33,
per_page: 5,
current_page: 1,
last_page: 7,
next_page_url: "http://ift.tt/29J1etJ",
prev_page_url: null,
from: 1,
to: 5,

... and the first 5 results.

When I click to the next page URL it's loading the exact same first page results and I have the exact same response:

total: 33,
per_page: 5,
current_page: 1,
last_page: 7,
next_page_url: "http://ift.tt/29J1etJ",
prev_page_url: null,
from: 1,
to: 5,

...with the same 5 first posts.

I haven't changed any settings in Laravel and I'm using Laravel 5.2.

Can anyone tell me what am I missing here?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire