Laravel : Eloquent Skip records

纵然是瞬间 提交于 2020-01-11 11:56:07

问题


How did i get my users but start only at a certain position ? I get the 50 first with :

$users = User::orderBy('xp', 'DESC')->take(50)->get();

But now I want the 50 after this, so the 50th to 100th records.

Thanks


回答1:


You can use skip()

Laravel eloqunt provides nice way to achieve this.

$users = User::orderBy('xp', 'DESC')->skip(50)->take(50)->get();

Hope this helps.



来源:https://stackoverflow.com/questions/46693044/laravel-eloquent-skip-records

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!