Multiple pagination with Laravel (2 pagination in 1 page)

Submitted by Mahmoud_Zalt - 9 years ago

How to add Multiple pagination in one page

// Controller

// Change the page name before you make the paginator:

Paginator::setPageName('page_a');
$collection_A = ModelA::paginate(10);

Paginator::setPageName('page_b');
$collection_B = ModelB::paginate(10);


// View

// Do the same: change the page name before you print the links

Paginator::setPageName('page_a');
$collection_A->links();

Paginator::setPageName('page_b');
$collection_B->links();
// If you don't want to lose any page state while you navigate to another page, append to the links the current page from all collections:

Paginator::setPageName('page_a');
$collection_A->appends('page_b', Input::get('page_b',1))->links();

Paginator::setPageName('page_b');
$collection_B->appends('page_a', Input::get('page_a',1))->links();