<?php

namespace App\Filament\Widgets;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use App\Models\User;
use App\Models\Marriage;

class FamilyStatsWidget extends BaseWidget
{
    protected function getStats(): array
    {
        $familyQuery = User::where('id', '!=', 1);

        return [
            Stat::make('Jumlah Ahli Keluarga', (clone $familyQuery)->count())
                ->description('Keseluruhan ahli dalam sistem')
                ->descriptionIcon('heroicon-m-users')
                ->color('success'),
            
            Stat::make('Jumlah Lelaki', (clone $familyQuery)->where('gender', 'Lelaki')->count())
                ->descriptionIcon('heroicon-m-user')
                ->color('primary'),
                
            Stat::make('Jumlah Perempuan', (clone $familyQuery)->where('gender', 'Perempuan')->count())
                ->descriptionIcon('heroicon-m-user')
                ->color('danger'),
                
            Stat::make('Jumlah Pasangan', Marriage::count())
                ->description('Rekod perkahwinan')
                ->descriptionIcon('heroicon-m-heart')
                ->color('warning'),
        ];
    }
}
