<?php

namespace App\Models;

use App\Traits\HasSortsTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
 * @phpstan-import-type ThumbSize from App\Services\ImageService
 *
 * @property int $id
 * @property string|null $cedula
 * @property string $nombre
 * @property string $apellido
 * @property int $id
 * @property int $id
 * @property Image|null $image
 * @property bool $estado
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property-write string $imageUrl
 */
class Persona extends Model
{
    use HasFactory, HasSortsTrait;

    protected $table = 'personas';

    protected $fillable = [
        'cedula',
        'nombre',
        'apellido',
        'imagen',
        'estado',
    ];

    protected $casts = [
        'estado' => 'bool',
    ];

    /** @var ThumbSize */
    protected string $imageThumbSize = 'medium';

    public function image()
    {
        return $this->morphOne(Image::class, 'imageable');
    }

    /**
     * @param ThumbSize $size
     */
    public function setImageThumbSize($size)
    {
        $this->imageThumbSize = $size;
    }

    public function getImageThumbSize()
    {
        return $this->imageThumbSize;
    }

    public function getFillable()
    {
        return $this->fillable;
    }
}
