Laravel 分页聊天不工作

Laravel paginate chat not working

我有代码:

$conversations = Chat::conversations()->for($user)->limit(1)->page(1)->get();

这个returnLengthAwarePaginator。但是 currentPage 来自 get 请求并没有改变。

仅在工作:

$conversations = Chat::conversations()->for($user)->limit(1)->page($request->get('page'))->get();

为什么?

我使用的包:https://github.com/musonza/chat

此代码始终 returns 第一页,因为您对其进行了硬编码:

->page(1)

Laravel的分页功能内部使用了$request->page,所以你不需要手动指定当前页。但是在这个包中你需要这样做,所以只需使用这个代码:

Chat::conversations()->for($user)->limit(1)->page($request->page)->get();