<?php

namespace App\Filament\Resources\FosteringApplications\Widgets;

use App\Models\FosteringApplication;
use App\Models\User;
use Filament\Widgets\Widget;

class ApplicantDetailsWidget extends Widget
{
    protected string $view = 'filament.resources.fostering-applications.widgets.applicant-details-widget';

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

    public ?FosteringApplication $record = null;

    /**
     * @return ?User
     */
    public function getApplicant()
    {
        return $this->record?->user;
    }

    public function getTotalApplications(): int
    {
        return $this->getApplicant()?->fosteringApplications()->count() ?? 0;
    }
}
