laravel 如何在 Lumen 中应用分页?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32022756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:11:38  来源:igfitidea点击:

How to apply pagination in Lumen?

laravellumen

提问by Volatil3

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

我怎样才能让我的页面分页,以便它显示 10 条记录/页。我已经在 Laravel 中做到了这一点,但不知道如何在 Lumen 中做到这一点

回答by Alan Ktquez

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

分页在 Lumen 中可用。您将执行与在 Laravel 中相同的操作。这是文档: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.

我自己在 Lumen 的第 5 版中使用过它,我可以告诉你它的工作原理是一样的。

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

前任。 $users = DB::table('posts')->paginate(10);

回答by Eduardo Cuomo

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 skipand takemethods:

要限制查询返回的结果数量,或跳过查询中给定数量的结果 ( OFFSET),您可以使用skiptake方法:

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

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

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