= 0; $i--) { $month = now()->subMonths($i); $labels[] = $month->format('M Y'); $data[] = Employee::query() ->whereNotNull('hire_date') ->whereYear('hire_date', $month->year) ->whereMonth('hire_date', $month->month) ->count(); } return [ 'datasets' => [ [ 'label' => 'New Hires', 'data' => $data, 'backgroundColor' => '#3b82f6', ], ], 'labels' => $labels, ]; } }