count(); // Incomplete donations in last 7 days (people who tried to give but something went wrong) $incomplete7d = Donation::whereDoesntHave('donationConfirmation', fn ($q) => $q->whereNotNull('confirmed_at')) ->where('created_at', '>=', now()->subDays(7)) ->count(); // Regular giving that recently stopped $cancelledSG = ScheduledGivingDonation::where('is_active', false) ->where('updated_at', '>=', now()->subDays(30)) ->count(); // System errors $errorsToday = EventLog::whereDate('created_at', today()) ->whereIn('status', ['failed', 'exception']) ->count(); return [ Stat::make('Fundraisers to Review', $pendingReview) ->description($pendingReview > 0 ? 'People are waiting for approval' : 'All caught up!') ->descriptionIcon($pendingReview > 0 ? 'heroicon-m-clock' : 'heroicon-m-check-circle') ->color($pendingReview > 20 ? 'danger' : ($pendingReview > 0 ? 'warning' : 'success')) ->url(route('filament.admin.resources.approval-queues.index')), Stat::make('Incomplete Donations', $incomplete7d) ->description('Last 7 days — people tried but payment didn\'t complete') ->descriptionIcon('heroicon-m-exclamation-triangle') ->color($incomplete7d > 50 ? 'danger' : ($incomplete7d > 0 ? 'warning' : 'success')), Stat::make('Cancelled Subscriptions', $cancelledSG) ->description('Monthly supporters who stopped in last 30 days') ->descriptionIcon($cancelledSG > 0 ? 'heroicon-m-arrow-down' : 'heroicon-m-check-circle') ->color($cancelledSG > 5 ? 'warning' : 'success'), Stat::make('System Problems', $errorsToday) ->description($errorsToday > 0 ? 'Errors today — check activity log' : 'No problems today') ->descriptionIcon($errorsToday > 0 ? 'heroicon-m-x-circle' : 'heroicon-m-check-circle') ->color($errorsToday > 0 ? 'danger' : 'success') ->url(route('filament.admin.resources.event-logs.index')), ]; } }