<?php

namespace App\Filament\Widgets;

use App\Models\Inquiry;
use App\Models\Job;
use App\Models\Post;
use App\Models\Project;
use App\Models\Service;
use Filament\Widgets\StatsOverviewWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class ContentOverview extends StatsOverviewWidget
{
    protected function getStats(): array
    {
        $openInquiries = Inquiry::query()->whereIn('status', ['neu', 'in_bearbeitung'])->count();

        return [
            Stat::make('Offene Anfragen', $openInquiries)
                ->description($openInquiries === 1 ? 'Persönlich beantworten' : 'Persönlich beantworten')
                ->color($openInquiries > 0 ? 'warning' : 'success')
                ->url(route('filament.admin.resources.inquiries.index')),
            Stat::make('Leistungen online', Service::published()->count())
                ->description('Start- und Detailseiten')
                ->color('primary')
                ->url(route('filament.admin.resources.services.index')),
            Stat::make('Beiträge online', Post::published()->count())
                ->description('Wissen und Aktuelles')
                ->color('primary')
                ->url(route('filament.admin.resources.posts.index')),
            Stat::make('Jobs / Referenzen', Job::published()->count().' / '.Project::published()->count())
                ->description('Veröffentlichte Inhalte')
                ->url(route('filament.admin.resources.jobs.index')),
        ];
    }
}
