I have many to many relations. Product, Category and category_product as pivot. I want to fetch Product through Category but I need each Category 10 Product.
here is my query
 Category::with(['grocery_product')->get();
Category model :
   public function grocery_product(): BelongsToMany
   {
       return $this->belongsToMany(Product::class)->limit(10);
   }
but here limit is not working. if I remove limit(10) then I get all products associated with that Category.
Note: I have tried with take(10) function also.
How to fetch each category's 10 products?
 
     
    