简体   繁体   English

如何使用雄辩的laravel 5.3获取特定批次的表行?

[英]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.

相关问题 Laravel雄辩的模型-使用中间表获取行 - Laravel eloquent model - get rows using intermediate table Laravel 5.3雄辩的模型动态表属性 - Laravel 5.3 Eloquent Model Dynamic Table Property 使用Eloquent在Laravel 5.3中按数据透视表过滤 - Use Eloquent to filter by pivot table in Laravel 5.3 如何使用Laravel Eloquent获取特定的成绩数据? - How to get a specific grade data using Laravel Eloquent? 使用带有Eloquent / Laravel 5.3的save()更新我的表是更新所有行而不是一行 - Updating my table with save () with Eloquent/Laravel 5.3 is updating all rows instead of one Laravel 5.3多态多对多-如何获取所有相关行,而不管其表是否按数据透视表列排序? - Laravel 5.3 Polymorphic many to many - how to get all the related rows regardless of their table sorted by pivot column? 在 Laravel Eloquent 中使用“With()”获取特定列 - Get Specific Columns Using “With()” Function in Laravel Eloquent 在Laravel 5.6中使用雄辩的方法从表及其数据透视表中获取已过滤的行 - Get filtered rows from a table and its pivot table using eloquent in laravel 5.6 如何在雄辩的榜样上创造条件? (Laravel 5.3) - How to create the conditions on the model of eloquent? (Laravel 5.3) 如何在Laravel 5.3雄辩的模型中定义关系? - How to define relation in laravel 5.3 eloquent model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM