Level 1
$test = DB::table('commandes') ->select('id_produit', DB::raw('COUNT(id_produit) as qte')) ->groupby('id_produit') ->havingRaw('COUNT(id_produit)') ->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
please can any one tell me how can i convert this query to eloquent query builder
SELECT id_produit , COUNT(id_produit) FROM commandes GROUP BY id_produit ;
Thank u all
$test = DB::table('commandes') ->select('id_produit', DB::raw('COUNT(id_produit) as qte')) ->groupby('id_produit') ->havingRaw('COUNT(id_produit)') ->get();
Please or to participate in this conversation.