$q->whereNotNull('confirmed_at')) ->whereDate('created_at', today()) ->count(); $todayAmount = Donation::whereHas('donationConfirmation', fn ($q) => $q->whereNotNull('confirmed_at')) ->whereDate('created_at', today()) ->sum('amount') / 100; return "Today: {$todayCount} confirmed (£" . number_format($todayAmount, 0) . ")"; } public function getTabs(): array { $incompleteCount = Donation::whereDoesntHave('donationConfirmation', fn ($q) => $q->whereNotNull('confirmed_at')) ->where('created_at', '>=', now()->subDays(7)) ->count(); $recurring = Donation::where('reoccurrence', '!=', -1) ->whereHas('donationConfirmation', fn ($q) => $q->whereNotNull('confirmed_at')) ->count(); return [ 'today' => Tab::make('Today') ->icon('heroicon-o-clock') ->modifyQueryUsing(fn (Builder $query) => $query ->whereDate('created_at', today()) ->whereHas('donationConfirmation', fn ($q) => $q->whereNotNull('confirmed_at')) ), 'all_confirmed' => Tab::make('All Confirmed') ->icon('heroicon-o-check-circle') ->modifyQueryUsing(fn (Builder $query) => $query ->whereHas('donationConfirmation', fn ($q) => $q->whereNotNull('confirmed_at')) ), 'incomplete' => Tab::make('Incomplete') ->icon('heroicon-o-exclamation-triangle') ->badge($incompleteCount > 0 ? $incompleteCount : null) ->badgeColor('danger') ->modifyQueryUsing(fn (Builder $query) => $query ->whereDoesntHave('donationConfirmation', fn ($q) => $q->whereNotNull('confirmed_at')) ->where('created_at', '>=', now()->subDays(7)) ), 'zakat' => Tab::make('Zakat') ->icon('heroicon-o-star') ->modifyQueryUsing(fn (Builder $query) => $query ->whereHas('donationConfirmation', fn ($q) => $q->whereNotNull('confirmed_at')) ->whereHas('donationPreferences', fn ($q) => $q->where('is_zakat', true)) ), 'gift_aid' => Tab::make('Gift Aid') ->icon('heroicon-o-gift') ->modifyQueryUsing(fn (Builder $query) => $query ->whereHas('donationConfirmation', fn ($q) => $q->whereNotNull('confirmed_at')) ->whereHas('donationPreferences', fn ($q) => $q->where('is_gift_aid', true)) ), 'recurring' => Tab::make('Recurring') ->icon('heroicon-o-arrow-path') ->badge($recurring > 0 ? $recurring : null) ->badgeColor('info') ->modifyQueryUsing(fn (Builder $q) => $q->where('reoccurrence', '!=', -1) ->whereHas('donationConfirmation', fn ($sub) => $sub->whereNotNull('confirmed_at'))), 'everything' => Tab::make('Everything') ->icon('heroicon-o-squares-2x2'), ]; } public function getDefaultActiveTab(): string | int | null { return 'today'; } }