<?php

declare(strict_types=1);

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

    public $timestamps = false;

    protected $table = 'signature_evidences';

    protected $fillable = [
        'tenant_id', 'signature_request_id', 'signer_id', 'kind', 'payload',
        'ip', 'user_agent', 'device', 'created_at',
    ];

    protected function casts(): array
    {
        return [
            'payload' => 'array',
            'created_at' => 'datetime',
        ];
    }

    public function request(): BelongsTo
    {
        return $this->belongsTo(SignatureRequestModel::class, 'signature_request_id');
    }

    public function signer(): BelongsTo
    {
        return $this->belongsTo(SignerModel::class, 'signer_id');
    }
}
