Answer the question
In order to leave comments, you need to log in
How to get weekly data?
There is data in this style, I need to get data for the current week and a week before the current one. If today is Wednesday, then you need data from Monday to today. I found data about the current week that can be obtained through Carbon
Carbon::setWeekStartsAt(Carbon::MONDAY);
Carbon::setWeekEndsAt(Carbon::SUNDAY);
$startOfWeek = $sales->whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])->get();
Answer the question
In order to leave comments, you need to log in
subtract 7 days from current date ?
$startOfWeek = $sales->whereBetween('created_at', [
Carbon::now()->subDays(7)->startOfWeek(),
Carbon::now()->subDays(7)->endOfWeek()
])->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question