I'm having some trouble with my pagination. I'm having two tables with data from a database and I paginated it with laravel Paginator.
Now my problem is when you go to, for example, page 2 it adds ?page=2 but that makes the first table go to page 2 too.
Is there anyway to get something like this ?
page_table1={number}&page_table2={number}
so you don't apply the page change on other tables.
Unfortunately I can't test this code right now, but browsing at the docs and the code (in
Illuminate/Pagination/Environment
) I guess you could something like this:The
setPageName()
method isn't documented in the docs, but it's a public method alongside those indicated in the documentation, so it should be working fine. FOr reference, this is the declaration (l. 171-180 invendor/laravel/framework/src/Illuminate/Pagination/Environment.php
):Now take into consideration that you will have another query string appended to the url, so you need to tell the pagination to consider it. Use the
appends()
method:That is, tell each Presenter to build up the url with all the query strings (the array resulting from
Request::query()
without the current index used by the paginator, or you'll end up with a double value).array_except()
is a Laravel built in array helper that returns the given array (1st parameter) purged of the passed index (2nd parameter).I'll try to test this code as soon as I can, but it should work. Let me know in any case!