Is there a way to “limit” the result with ELOQUENT ORM of Laravel?

后端 未结 4 656
深忆病人
深忆病人 2020-11-30 21:54

Is there a way to \"limit\" the result with ELOQUENT ORM of Laravel?

 SELECT * FROM  `games` LIMIT 30 , 30 

And with Eloquent ?

4条回答
  •  佛祖请我去吃肉
    2020-11-30 22:05

    If you're looking to paginate results, use the integrated paginator, it works great!

    $games = Game::paginate(30);
    // $games->results = the 30 you asked for
    // $games->links() = the links to next, previous, etc pages
    

提交回复
热议问题