Laravel Pagination

Pagination with Laravel (5.4 at the time of writing) is very easy.

Say you want a table of users

In your controller:

$user = User::all()->paginate(10);

In the view loop through your users as normal and then add

$user->links() where ever you feel like it and more than one place if you are feeling dandy.

There is more..

But say you want more than one paginate-able list/table on the same page? This is the paginators signature

paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)

Easy, extending the original query lets get all the threads/comments for a user. Assuming your User model can dish out Threads and Comments

$user = User::find(1);
$threads = $user->threads()->paginate(4, ['*'], 'threads');
$comments = $user->comments()->paginate(4, ['*'], 'comments');

Then in your view loop through your comments and add

$comments->links();

Loop through your threads and add

$threads->links();