<?php

namespace App\Models;

use CodeIgniter\Model;

class TipoCertificadoModel extends Model
{
    protected $table            = 'tipo_certificado';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'array';
    protected $useSoftDeletes   = true;
    protected $protectFields    = true;
    protected $allowedFields    = [
        'nombre',
        'descripcion',
        'icono',
        'activo'
    ];

    // Dates
    protected $useTimestamps = true;
    protected $dateFormat    = 'datetime';
    protected $createdField  = 'created_at';
    protected $updatedField  = 'updated_at';
    protected $deletedField  = 'deleted_at';

    /**
     * Obtiene todos los tipos de certificados activos
     * 
     * @return array Lista de tipos de certificados activos
     */
    public function getActivos(): array
    {
        return $this->where('activo', 1)
                    ->where('deleted_at', null)
                    ->orderBy('nombre', 'ASC')
                    ->findAll();
    }
}