<?php

declare(strict_types=1);

namespace App\Models;

use CodeIgniter\Model;

class LeadCallTranscriptModel extends Model
{
    protected $table            = 'lead_call_transcripts';
    protected $primaryKey       = 'id';
    protected $returnType       = 'array';
    protected $useSoftDeletes   = false;
    protected $allowedFields    = [
        'call_id',
        'transcript_text',
        'speaker_segments',
        'language',
        'ai_summary',
        'ai_summary_status',
        'raw_json',
    ];
    protected $useTimestamps    = true;
    protected $createdField     = 'created_at';
    protected $updatedField     = 'updated_at';

    public function findByCallId(int $callId): ?array
    {
        $row = $this->where('call_id', $callId)->first();
        return $row ?: null;
    }
}
