简体   繁体   English

Laravel paginator,自定义页码值

[英]Laravel paginator, custom page number value

Trying to create custom pagination on Laravel,尝试在 Laravel 上创建自定义分页,

I am tring to paginate a collection build with values from two entities (users, organisations)我正在尝试使用来自两个实体(用户、组织)的值对集合构建进行分页

Is there any way to change the page number value to a custom value?有没有办法将页码值更改为自定义值?

Or can i append custom query string and value to each page url?或者我可以 append 为每个页面 url 自定义查询字符串和值吗?

you can use skip() and take() for custom pagination.您可以使用 skip() 和 take() 进行自定义分页。

skip() will work as offset and take() will work as a limit. skip() 将用作偏移量,而 take() 将用作限制。

ex.前任。 page = 0;页 = 0; offset = 0;偏移量 = 0; limit = 10;限制= 10;

offset = page * limit;偏移量=页面*限制;

limit = 10;限制= 10;

query->skip(offset)->take(limit)->get(); query->skip(offset)->take(limit)->get();

You can pass the values of page number & limit to your query.您可以将页码和限制的值传递给您的查询。

Value of limit should be greater than 0 limit 的值应大于 0

Hope this will work for you.希望这对你有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM