I have my SQL request which works in phpmyadmin but in the eloquent request it does not work because of the group by
Please help me and thank you in advance!
Code php(Laravel) $top10 = sales::where('id_user', Auth::id())
->whereYear('created_at', $currentYear)
->whereMonth('created_at', $currentMonth)
->selectRaw('id_article, COUNT(*) as count')
->groupBy('id_article')
->orderByDesc('count')
->limit(10)
->get();
Request SQL : select id_article, COUNT(*) as count, id_client from `ventes` where `id_user` = 2 and year(`created_at`) = 2020 and month(`created_at`) = 06 group by `id_article` order by `count` desc limit 10