map(fn ($i) => Carbon::now()->subDays($i))->toArray(); $projectsData = array_map( fn (Carbon $date) => Project::query() ->whereDate('created_at', '<=', $date) ->published() ->count(), $last30Days ); $membersData = array_map( fn (Carbon $date) => Member::query() ->whereDate('created_at', '<=', $date) ->public() ->count(), $last30Days ); $issuesData = array_map( fn (Carbon $date) => RepositoryIssue::query() ->whereDate('created_at', '<=', $date) ->where('is_good_first_issue', true) ->count(), $last30Days ); return [ 'datasets' => [ [ 'label' => __('panel.widgets.growth.projects'), 'data' => $projectsData, 'borderColor' => '#3b82f6', 'backgroundColor' => 'rgba(59, 130, 246, 0.1)', 'tension' => 0.4, ], [ 'label' => __('panel.widgets.growth.members'), 'data' => $membersData, 'borderColor' => '#10b981', 'backgroundColor' => 'rgba(16, 185, 129, 0.1)', 'tension' => 0.4, ], [ 'label' => __('panel.widgets.growth.issues'), 'data' => $issuesData, 'borderColor' => '#f59e0b', 'backgroundColor' => 'rgba(245, 158, 11, 0.1)', 'tension' => 0.4, ], ], 'labels' => array_map(fn (Carbon $date) => $date->format('M d'), $last30Days), ]; } protected function getType(): string { return 'line'; } protected function getOptions(): array { return [ 'scales' => [ 'y' => [ 'beginAtZero' => true, ], ], 'plugins' => [ 'legend' => [ 'display' => true, ], ], ]; } public static function canView(): bool { return auth()->user()?->can('projects.view_any') ?? false; } }