Laravel Count and GroupBy Field Query

I have been busy developing an e-commerce platform from zero to fulfill this semester project for Web Programming Course.

I need to select 5 the most popular product based on customer order. Customer order is stored in order_details table. To make a that query in laravel, try this:

Based on code snippet above, it will return 5 product_id as the most ordered product.

p/s: my 2016 mission, be a morning person!

Leave a Reply

Your email address will not be published. Required fields are marked *