select( DB::raw('COUNT(*) as count'), DB::raw("DATE_FORMAT(created_at, '%Y-%m') as month") ) ->where('created_at', '>=', now()->subMonths(6)) ->groupBy('month') ->orderBy('month') ->get(); return [ 'datasets' => [ [ 'label' => 'Media Baru', 'data' => $data->pluck('count')->toArray(), 'fill' => 'start', 'borderColor' => '#10B981', 'backgroundColor' => 'rgba(16, 185, 129, 0.1)', ], ], 'labels' => $data->pluck('month')->map(fn ($m) => \Carbon\Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(), ]; } protected function getType(): string { return 'line'; } }