i have three table one is category
table and another is product
table and one more product_to_category
table, and it has only product_id
and category_id
column.
Now i want to get top 10 categories with maximum number of product, with details of 10 products from each category.
What i wrote is
$result = ProductToCategory::groupBy('category_id')->with(['product',function($q){
$q->take(10);
}])->orderBy('category_id)->take(10);
But this is not working.How to write this query properly Can anyone please help. ty
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire