theProfit's avatar

DB Pagination RESTFULL + Extra query's

Hi Everybody,

When you have a restfull api and you do this by Pagination is there a proper way to use extra querys this because paginate will also make the urls for next page ect. witch if you use ?language=NL and some other parameters this must also go with the next page.

0 likes
5 replies
kossa's avatar

Use Do..While until the next page is null :)

theProfit's avatar

No i don't mean to extract but to build for example :

return Products::all()->paginate(100);

this you would put in a controller so then you request /api/products and you will get the result. easy only when you want /api/products?language=NL you can make it in the query but paginate won't change the next page url with the query is there a way to do this?

else when somebody goes to the next page it will lose ?language=NL&page=2.

SilenceBringer's avatar
Level 55

@kossa use appends method on LengthAwarePaginator instance

return Products::paginate(100)->appends(['language' => 'NL']);

Please or to participate in this conversation.