Set Kyar Wa Lar
Set Kyar Wa Lar

Reputation: 4634

How do I get previous pagination data in Laravel?

I try something like that

User::paginate(10);

And when I click 2 via my view it's go /?page=2 and it's just show after record 10. How do I get previous pagination data?

Why I want to get the previous data? Don't want to go with 1,2,3, pagination. Want to show 10 records, 20 records, 30 records and etc.

Upvotes: 1

Views: 299

Answers (2)

Pawel Bieszczad
Pawel Bieszczad

Reputation: 13325

When changing the page size in the dropdown menu (lets say the field name is pageSize)you want to send the request to the controller again, query the data and paginate with the selected value.

User::paginate(Input:get('pageSize', 10));

Upvotes: 2

ntzm
ntzm

Reputation: 4821

In your view, change:

$users->render();

to:

$users->appends(['foo' => 'bar'])->render();

Where you obviously replace foo and bar with the data you want to passed to the rest of the pages.

Documentation

Upvotes: 1

Related Questions