<?php

namespace App\Models\OrdenTrabajo;

use App\Entities\Produccion\OrdenTrabajoUserEntity;
use App\Models\Usuarios\UserModel;
use CodeIgniter\Database\MySQLi\Builder;
use CodeIgniter\Model;

class OrdenTrabajoUser extends Model
{
    protected $table            = 'orden_trabajo_users';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = OrdenTrabajoUserEntity::class;
    protected $useSoftDeletes   = true;
    protected $protectFields    = true;
    protected $allowedFields    = [
        "orden_trabajo_id",
        "user_created_id",
        "user_update_id",
        //IMPRESION
        "interior_bn_user_id",
        "interior_color_user_id",
        "cubierta_user_id",
        //ACABADO
        "plastificado_user_id",
        "encuadernacion_user_id",
        "corte_user_id",
        "preparacion_interior_user_id",
        "entrada_manipulado_user_id",
        "cosido_user_id",
        "solapa_user_id",
        "grapado_user_id",
        "retractilado_user_id",
        "retractilado5_user_id",
        "prototipo_user_id",
        "marcapaginas_user_id",
        "espiral_user_id",
        //FERRO
        "pendiente_ferro_user_id",
        "ferro_en_cliente_user_id",
        "ferro_ok_user_id",
        //ENVIO
        "embalaje_user_id",
        "envio_user_id",
        //PREIMPRESION
        "pre_formato_user_id",
        "pre_lomo_user_id",
        "pre_solapa_user_id",
        "pre_codbarras_user_id",
        "pre_imposicion_user_id",
        //UNUSED
        "inaplazable_revised_change_user_id",//!DELETE
        "ferro_disponible_hecho_user_id",//!DELETE
        "ferro_entregado_user_id",//!DELETE
        "pre_imprimir_user_id", //!DELETE
        "ferro_disponible_ok_user_id", //!DELETE
    ];

    protected bool $allowEmptyInserts = false;
    protected bool $updateOnlyChanged = true;


    protected array $castHandlers = [];

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

    // Validation
    protected $validationRules      = [];
    protected $validationMessages   = [];
    protected $skipValidation       = false;
    protected $cleanValidationRules = true;

    // Callbacks
    protected $allowCallbacks = true;
    protected $beforeInsert   = [];
    protected $afterInsert    = [];
    protected $beforeUpdate   = [];
    protected $afterUpdate    = [];
    protected $beforeFind     = [];
    protected $afterFind      = [];
    protected $beforeDelete   = [];
    protected $afterDelete    = [];


}
