Reputation: 2055
I am implementing multiple pagination in laravel 5. I know it could be achieved by using setPageName() as refer from Laravel 5 pagination, won't move through pages with custom page name
I know the issue already been resolved in 5.1. So I've updated my laravel by changing the laravel version in composer.json from "laravel/framework":5.0 to 5.1.10 and run composer update.
But the problem still exist. I can't set any page name for the page and the problem is exactly same in the link i've posted above. Only if i put the SetPageName('page') it will work perfectly.
Am I missing out something after I run the composer update ?
Upvotes: 1
Views: 2307
Reputation: 4850
The solution is passing a third argument to paginate() method:
$publishedArticles = Article::paginate(10, ['*'], 'published');
$unpublishedArticles = Article::paginate(10, ['*'], 'unpublished');
The URL:
laravel/public/articles?published=3
laravel/public/articles?unpublished=1
Upvotes: 1
Reputation: 205
Laravel Multiple Pagination in one page
I tried to make it work using the solution as mentioned in the above link, but it did not worked for me..
# use default 'page' for this
$data['test'] = $client->OpportunityList()->paginate(4);
# use custom 'opage' for this
$data['test'] = $client->OpportunityList()->paginate(4);
$data['test']->setPageName('opage');
These did not worked for me, so I passed the page name in the main paginate function - https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Builder.php#L271
Working Code
$data['test'] = $client->OpportunityList()->paginate(4, ['*'], 'opage');
Works for simplePaginate as well - refer - https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Builder.php#L294
Upvotes: 3