To get the total number of orders by weekday, I use:
Order::select('*')
->get()
->groupBy(function($date) {
return Carbon::parse($date->created_at)->format('l');
});
What I would like to add is that it returns, per weekday, the count of the items that were ordered, which is a property on the Order model called item_count
. I tried using sum()
on the query but that doesn't work.