How to get the daily record and sum them up, plus group it by date? Please see my code below.
$sales = DB::table("orders") ->where('status', 8) ->select( 'grand_total', 'order_date', DB::raw("SUM(grand_total) as total_sales") ) ->groupBy('order_date') ->get(); dd($sales);
It returns the right dates, but wrong sales. How can I sum sales each day?