0

In controller i have two queries like:

    $results1 = Something1::with('something2')
                          ->where_instance_id(...)
                          ->where_page_id(2)
                          ->where_in('status',array('bla','blabla'))
                          ->paginate(10);

    $results2 = Something1::with('something2')
                          ->where_instance_id(...)
                          ->where_page_id(4)
                          ->where_in('status',array('bla','blabla'))
                          ->paginate(10);

And then in the one view(one page) i have two physical page. One of them through table will describe $results1 and one will describe $results2.

Problems is with that laravel 3 doesn't support two pagination on one page? When i do something like:

    {{ $results1->links() }}
    {{ $results2->links() }}

it doesn't work, when i click on the button for the pagination for $results1 i change the view also for $results2, and vice versa.

NOTE: I can't make two views.
Any idea or alternative way to solve this?

Thanks.

Srle
  • 10,366
  • 8
  • 34
  • 63

1 Answers1

1

It is ugly, dirty, not fully tested, and I'm missing the append for the links, but:

$Bar = new Bar;
$Bar->paginate(); // will use page=x

$Foo = new Foo;
$P = clone($Foo->getConnection()->getPaginator());
$P->setPageName('section');
$Foo->getConnection()->setPaginator($P);
$Foo->paginate(); // will use section=x

You can use 2 lists on 1 page now, but you can't navigate to page=3 and then to section=2 because the page=3 will disappear - this is where you need to figure out some append() logix that works.

[edit] and.... this piece of code is for L4, didn't notice the L3 tag. frack me.

Rob Gordijn
  • 6,381
  • 1
  • 22
  • 29
  • May be a bit ugly but it sure saved my butt. I was just having this exact problem because I have tabs with a paginated list of results in each tab. Naturally it counts as one page, so it wouldn't work in Laravel. So far it appears to work correctly (as long as I make sure to set the tab based on which list was last paginated). – JaidynReiman Aug 23 '13 at 06:46