Laravel 5 Pagination: Multiple Paginations in the same Page


In this note I write down my experience regarding multiple paginationin the same page using Laravel 5:

In your laravel controller:


//  Program Degree
$object1s = Object1::orderBy('name', 'desc')
                    ->paginate(2, ['*'], 'page_1s');

// Master Program
$object2s = Object2::orderBy('name', 'desc')
                    ->paginate(2, ['*'], 'page_2s');

// Online Course
$object3s = Object3::orderBy('name', 'desc')
                    ->paginate(2, ['*'], 'page_3s');

In your laravel view:

  // Nothing to change in the view

Now you will have following paginated urls in your application:

  1. http://localhost:8000/yourpage?page_1s=2
  2. http://localhost:8000/yourpage?page_2s=2
  3. http://localhost:8000/yourpage?page_3s=2
  4. for special purpose you can custom url to handle all paginations in same time become:
    1. http://localhost:8000/yourpage?page_1s=2&page_2s=3&page_3s=4
Advertisements

One thought on “Laravel 5 Pagination: Multiple Paginations in the same Page

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s