<?php

declare(strict_types=1);

namespace App\Models;

use CodeIgniter\Model;

class VapiCallScoreModel extends Model
{
    protected $table            = 'vapi_call_scores';
    protected $primaryKey       = 'id';
    protected $returnType       = 'array';
    protected $useSoftDeletes   = false;
    protected $allowedFields    = [
        'call_log_id',
        'score_pct',
        'pass_threshold_pct',
        'breakdown_json',
        'ai_feedback',
    ];
    protected $useTimestamps    = true;
    protected $createdField     = 'created_at';
    protected $updatedField     = 'updated_at';
    protected $validationRules  = [];
    protected $validationMessages = [];
    protected $skipValidation     = false;

    public function findByCallLogId(int $callLogId): ?array
    {
        $row = $this->where('call_log_id', $callLogId)->first();
        return $row ?: null;
    }
}
