filters['startDate'] ?? null; $endDate = $this->filters['endDate'] ?? null; $totalJournalists = Journalist::when($startDate, fn ($q) => $q->whereDate('created_at', '>=', $startDate)) ->when($endDate, fn ($q) => $q->whereDate('created_at', '<=', $endDate)) ->count(); $totalMedia = PartnerMedia::when($startDate, fn ($q) => $q->whereDate('created_at', '>=', $startDate)) ->when($endDate, fn ($q) => $q->whereDate('created_at', '<=', $endDate)) ->count(); $average = $totalMedia > 0 ? round($totalJournalists / $totalMedia, 1) : 0; return [ Stat::make('Total Perusahaan', Company::when($startDate, fn ($q) => $q->whereDate('created_at', '>=', $startDate)) ->when($endDate, fn ($q) => $q->whereDate('created_at', '<=', $endDate)) ->count()) ->description('Perusahaan terdaftar') ->descriptionIcon(Heroicon::OutlinedBuildingOffice2) ->color('primary'), Stat::make('Media Terverifikasi', PartnerMedia::whereHas('company.verificationRequest', function ($q) { $q->approved(); }) ->when($startDate, fn ($q) => $q->whereDate('created_at', '>=', $startDate)) ->when($endDate, fn ($q) => $q->whereDate('created_at', '<=', $endDate)) ->count()) ->description('Media aktif') ->descriptionIcon(Heroicon::OutlinedCheckBadge) ->color('success'), Stat::make('Total Jurnalis', Journalist::when($startDate, fn ($q) => $q->whereDate('created_at', '>=', $startDate)) ->when($endDate, fn ($q) => $q->whereDate('created_at', '<=', $endDate)) ->count()) ->description('Jurnalis terdaftar') ->descriptionIcon(Heroicon::OutlinedIdentification) ->color('info'), Stat::make('Antrean Verifikasi', VerificationRequest::pending() ->when($startDate, fn ($q) => $q->whereDate('created_at', '>=', $startDate)) ->when($endDate, fn ($q) => $q->whereDate('created_at', '<=', $endDate)) ->count()) ->description('Butuh tindakan') ->descriptionIcon(Heroicon::OutlinedPencilSquare) ->color('warning'), Stat::make('Antrean Perubahan', DataChangeRequest::pending() ->when($startDate, fn ($q) => $q->whereDate('created_at', '>=', $startDate)) ->when($endDate, fn ($q) => $q->whereDate('created_at', '<=', $endDate)) ->count()) ->description('Perubahan data') ->descriptionIcon(Heroicon::OutlinedDocumentText) ->color('warning'), Stat::make('Total Pengunjung', Visitor::when($startDate, fn ($q) => $q->whereDate('date', '>=', $startDate)) ->when($endDate, fn ($q) => $q->whereDate('date', '<=', $endDate)) ->count()) ->description('Total traffic') ->descriptionIcon(Heroicon::OutlinedChartBar) ->color('info'), Stat::make('Rata-rata Jurnalis / Media', $average) ->description('Rasio sebaran jurnalis') ->descriptionIcon(Heroicon::OutlinedUsers) ->color('primary'), ]; } }