laravel 4 - how to Limit (Take and Skip) for Eloquent ORM?

后端 未结 1 1695
感动是毒
感动是毒 2020-12-28 08:23

TL;DR

Can you limit an Eloquent ORM query like using take() and skip() so that the resulting mysql query is also limited, and it doesn\'t

相关标签:
1条回答
  • 2020-12-28 08:55
    User::find(1)->games()->take(3)->skip(2)->get();
    

    I think this should give you your collection. :)

    ->games will give you a collection, where ->games() will offer a query builder instance.

    Enjoy Laravel!

    0 讨论(0)
提交回复
热议问题