[英]How to get specific batch of rows of table using eloquent laravel 5.3?
I'm making a chat app using laravel. 我正在使用laravel制作聊天应用程序。 There is a button in top of the chat box which if it is pressed the 30 last messages before the last previous messages in the box are loaded to the box.
聊天框顶部有一个按钮,如果按下该按钮,则将框中的最后30条消息之前的30条最后一条消息加载到该框中。 I know how to get 30 last messages
(take methode)
from table but don't know how do it for next 30 last messages. 我知道如何从表中获取30条最新消息
(take methode)
,但是不知道接下来30条最新消息如何获取。 Can anyone help me please? 谁能帮我吗?
This is Message table columns: 这是消息表列:
content | from_id | to_id | created_at | users_id
------- --------- ------- ------------ ---------
hello | 39 | 12 | 7/6/2017 | 39:12
Hi i believe you can do this in laravel very easily 嗨,我相信您可以在laravel中轻松完成此操作
YourModel::paginate(30);
with this you can get data in paginated form and you dont have to use take
method 有了它,您可以以分页形式获取数据,而不必使用
take
方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.