简体   繁体   English

Laravel分页添加页码

[英]Laravel pagination add page number

Am sending a get request and adding the pagination value but now i would like to attach the page 我正在发送获取请求并添加分页值,但现在我想附加页面

So in my URL I have 所以在我的网址中

http://localhost:8080/users?paginator=10&page=1

The value of page and paginator are controlled from frontend(angular4) 页面和分页器的值由frontend(angular4)控制

So in my controller I have 所以在我的控制器中

class UserController extends Controller{

 public function index(){
   return User::paginate($request->paginator);
 }
}

The above works for the paginator value but now how do I attach the page number? 以上适用于分页器值,但是现在如何附加页码?

return User::paginate($request->paginator, ['*'], 'page', $request->page);

The default paginate method takes the following parameters. 默认的分页方法采用以下参数。

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

For further details, see this link. 有关详细信息,请参阅链接。

From the docs here : 这里的文档:

By default, the current page is detected by the value of the page query string argument on the HTTP request. 默认情况下,当前页面由HTTP请求上的页面查询字符串参数的值检测。

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

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