Files
safekat/ci4/app/Models/Configuracion/MaquinaOtTareaModel.php
2025-05-05 00:47:00 +02:00

67 lines
1.9 KiB
PHP
Executable File

<?php
namespace App\Models\Configuracion;
use App\Entities\Tarifas\Maquinas\MaquinaOtTareaEntity;
use App\Entities\Tarifas\Maquinas\TareaMaquinaEntity;
use CodeIgniter\Model;
class MaquinaOtTareaModel extends Model
{
protected $table = 'maquina_ot_tareas';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = MaquinaOtTareaEntity::class;
protected $useSoftDeletes = true;
protected $protectFields = true;
protected $allowedFields = [
"maquina_id",
"orden_trabajo_id",
];
protected bool $allowEmptyInserts = false;
protected bool $updateOnlyChanged = true;
protected array $casts = [];
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 = [];
public function queryDatatableJoinOrdenTrabajo($maquina_id){
return $this->builder()
->select([
'maquina_ot_tareas.id as maquinaOtTareaId',
'ordenes_trabajo.id as otId'
])
->join('ordenes_trabajo','ordenes_trabajo.id = maquina_ot_tareas.orden_trabajo_id','left')
->where('maquina_ot_tareas.maquina_id',$maquina_id)
->where('maquina_ot_tareas.deleted_at',null);
}
}