<?php

namespace App\Filament\Widgets;

use App\Models\Consultation;
use App\Models\Inquiry;
use Filament\Widgets\Widget;

class WelcomeBanner extends Widget
{
    protected string $view = 'filament.widgets.welcome-banner';

    protected int|string|array $columnSpan = 'full';

    protected static ?int $sort = -6;

    protected static bool $isLazy = false;

    public function getViewData(): array
    {
        $user = auth()->user();
        $hour = (int) now()->format('H');
        $greeting = $hour < 12 ? 'Good morning' : ($hour < 17 ? 'Good afternoon' : 'Good evening');

        return [
            'greeting' => $greeting,
            'name' => $user?->name ?? 'there',
            'today' => now()->format('l, j F Y'),
            'openConsultations' => Consultation::where('status', 'new')->count(),
            'openInquiries' => Inquiry::where('status', 'new')->count(),
        ];
    }
}
