Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply pagination in Lumen?

Tags:

laravel

lumen

How can I make my page paginated so that it shows 10 records/page. I have done this in Laravel but not sure how to do it in Lumen

like image 287
Volatil3 Avatar asked Aug 15 '15 07:08

Volatil3


2 Answers

Paginate is available in Lumen. You will do just the same as in Laravel. Here is the documentation: http://laravel.com/docs/5.1/pagination#basic-usage

I have myself used it in version 5 of Lumen and I can tell you that it works the same.

ex. $users = DB::table('posts')->paginate(10);

like image 136
Alan Ktquez Avatar answered Oct 19 '22 20:10

Alan Ktquez


skip / take

To limit the number of results returned from the query, or to skip a given number of results in the query (OFFSET), you may use the skip and take methods:

$users = DB::table('users')->skip(10)->take(5)->get();

Source: https://laravel.com/docs/5.1/queries#ordering-grouping-limit-and-offset

like image 33
Eduardo Cuomo Avatar answered Oct 19 '22 19:10

Eduardo Cuomo