<?php

declare(strict_types=1);

namespace App\Models;

use CodeIgniter\Model;

class LeadCallRecordingModel extends Model
{
    protected $table            = 'lead_call_recordings';
    protected $primaryKey       = 'id';
    protected $returnType       = 'array';
    protected $useSoftDeletes   = false;
    protected $allowedFields    = [
        'call_id',
        'recording_url',
        'file_path',
        'mime_type',
        'file_size',
        'duration_seconds',
        '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;
    }
}
