<?php

namespace App\Models;

use CodeIgniter\Model;

class PolicyDetailsModel extends Model
{
    protected $table            = 'c_policy_details';
    protected $primaryKey       = 'policy_details_id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'array';
    protected $useSoftDeletes   = false;

    protected $allowedFields    = [
        'policy_id', 
        'service_id', 
        'cost', 
        'class', 
        'a1_action', 
        'a2_action', 
        'a3_action', 
        'parallel_process_from',
        'a1_exceptional_action', 
        'a2_exceptional_action', 
        'a3_exceptional_action', 
        'a4_exceptional_action', 
        'exceptional_parallel_process_from',
        'a1_amendment_action', 
        'a2_amendment_action', 
        'a3_amendment_action', 
        'a4_amendment_action',
        'amendment_parallel_process_from',
        'is_active', 
        'created_on', 
        'created_by', 
        'updated_on', 
        'updated_by', 
    ];

    protected $useTimestamps = false; // Set to true if you have created_at & updated_at fields

    /**
     * Get policy details by policy ID
     */
    public function getPolicyDetails($policyId)
    {
        return $this->where('policy_id', $policyId)->findAll();
    }

    /**
     * Get active policy details
     */
    public function getActivePolicyDetails($policyId)
    {
        return $this->where(['policy_id' => $policyId, 'is_active' => 1])->findAll();
    }
}
