Level 102
Something like this?
foreach (range(1,12) as $i) {
$month = Carbon::create()->day(1)->month($i);
$counts[$i] = Model::whereBetween('date', $month, $month->copy()->endOfMonth())->count();
}
1 like
how do i count entries monthly 1st to last day of every month? i'm making use of datatable package from which month and year can be selected. i'd love an example. Thank you!
Something like this?
foreach (range(1,12) as $i) {
$month = Carbon::create()->day(1)->month($i);
$counts[$i] = Model::whereBetween('date', $month, $month->copy()->endOfMonth())->count();
}
Please or to participate in this conversation.