I am learning to use the laravel eloquent and I have this query
SELECT SUM(precio_total) FROM `venta` GROUP BY (MONTH(fecha));
So far i wear this
$cantidad_venta = Venta::select('SUM(PRECIO_TOTAL) as suma_precio')
->groupBy('MONTH(fecha)')
->get();
I try to go through axios, but it throws me an error
return response()->json($cantidad_venta);
I would really appreciate an answer, thank you very much
2
Answers
You can Do this in multiple ways. check the following code below :