filters['startDate'] ?? null; $endDate = $this->filters['endDate'] ?? null; $data = PartnerMedia::query() ->when($startDate, fn ($q) => $q->whereDate('created_at', '>=', $startDate)) ->when($endDate, fn ($q) => $q->whereDate('created_at', '<=', $endDate)) ->selectRaw('classification, count(*) as total') ->groupBy('classification') ->get(); $labels = []; $counts = []; foreach (MediaClassification::cases() as $case) { $labels[] = $case->getLabel(); $counts[] = $data->where('classification', $case)->first()?->total ?? 0; } return [ 'datasets' => [ [ 'label' => 'Jumlah Media', 'data' => $counts, 'backgroundColor' => '#4F46E5', ], ], 'labels' => $labels, ]; } protected function getType(): string { return 'bar'; } }