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

后端 未结 4 659
深忆病人
深忆病人 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:12

    Also, we can use it following ways

    To get only first

     $cat_details = DB::table('an_category')->where('slug', 'people')->first();
    

    To get by limit and offset

    $top_articles = DB::table('an_pages')->where('status',1)->limit(30)->offset(0)->orderBy('id', 'DESC')->get();
    $remaining_articles = DB::table('an_pages')->where('status',1)->limit(30)->offset(30)->orderBy('id', 'DESC')->get();
    

提交回复
热议问题