<?php

declare(strict_types=1);

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

    protected $table = 'lead_scores';

    protected $fillable = [
        'tenant_id',
        'human_handoff_id',
        'urgency_score',
        'interest_score',
        'properties_viewed',
        'requested_visit',
        'wait_minutes',
        'total_score',
        'factors',
    ];

    protected function casts(): array
    {
        return [
            'requested_visit' => 'boolean',
            'factors' => 'array',
        ];
    }

    public function handoff(): BelongsTo
    {
        return $this->belongsTo(HumanHandoffModel::class, 'human_handoff_id');
    }
}
