publiclyVisible() ->whereNotNull('primary_language') ->groupBy('primary_language') ->selectRaw('primary_language, COUNT(*) as count') ->orderByDesc('count') ->limit(10) ->get(); return [ 'datasets' => [ [ 'label' => __('panel.widgets.languages.repositories'), 'data' => $languages->pluck('count')->toArray(), 'backgroundColor' => [ '#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899', '#14b8a6', '#f97316', '#6366f1', '#06b6d4', ], 'borderColor' => '#fff', 'borderWidth' => 2, ], ], 'labels' => $languages->pluck('primary_language')->map(fn ($lang) => ucfirst($lang ?? 'Other'))->toArray(), ]; } protected function getType(): string { return 'doughnut'; } protected function getOptions(): array { return [ 'plugins' => [ 'legend' => [ 'position' => 'bottom', ], ], ]; } public static function canView(): bool { return auth()->user()?->can('projects.view_any') ?? false; } }