Laravel Eloquent limit and offset

前端 未结 9 980
陌清茗
陌清茗 2020-12-13 05:25

This is mine

    $art = Article::where(\'id\',$article)->firstOrFail();
    $products = $art->products;

I just wanna take a limit \'p

9条回答
  •  醉梦人生
    2020-12-13 06:00

    laravel have own function skip for offset and take for limit. just like below example of laravel query :-

    Article::where([['user_id','=',auth()->user()->id]])
                    ->where([['title','LIKE',"%".$text_val."%"]])
                    ->orderBy('id','DESC')
                    ->skip(0)
                    ->take(2)
                    ->get();
    

提交回复
热议问题