<?php

declare(strict_types=1);

namespace ImovelZapAi\ClientPortal\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 DocumentVersionModel extends Model
{
    use BelongsToTenant;
    use HasUuidPrimaryKey;

    protected $table = 'document_versions';

    protected $fillable = [
        'tenant_id', 'uploaded_document_id', 'version', 'disk', 'path',
        'original_name', 'mime', 'size_bytes', 'checksum', 'uploaded_via',
    ];

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

    public function uploadedDocument(): BelongsTo
    {
        return $this->belongsTo(UploadedDocumentModel::class, 'uploaded_document_id');
    }
}
