<?php

declare(strict_types=1);

namespace ImovelZapAi\Proposals\Infrastructure\Persistence\Eloquent;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\BelongsToTenant;
use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\HasUuidPrimaryKey;

class ProposalVersionModel extends Model
{
    use BelongsToTenant;
    use HasUuidPrimaryKey;

    protected $table = 'proposal_versions';

    protected $fillable = [
        'tenant_id', 'proposal_id', 'version', 'snapshot', 'html_body',
        'pdf_disk', 'pdf_path', 'change_summary', 'validation_code', 'created_by',
    ];

    protected function casts(): array
    {
        return [
            'version' => 'integer',
            'snapshot' => 'array',
        ];
    }

    public function proposal(): BelongsTo
    {
        return $this->belongsTo(ProposalModel::class, 'proposal_id');
    }
}
