<?php

namespace App\Filament\Resources\AssistanceApplications\Widgets;

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

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

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

    public ?AssistanceApplication $record = null;

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

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