delete is_deleted field

This commit is contained in:
amazuecos
2025-04-11 06:56:55 +02:00
parent 9e591a099d
commit 1e339b5503
11 changed files with 84 additions and 45 deletions

View File

@ -34,7 +34,6 @@ class ClientePreciosModel extends \App\Models\BaseModel
"tiempo_max",
"precio_hora",
"margen",
"is_deleted",
"deleted_at",
"created_at",
"updated_at",
@ -45,7 +44,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
protected $returnType = "App\Entities\Clientes\ClientePreciosEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $useSoftDeletes = true;
protected $deletedField = 'deleted_at';
protected $createdField = "created_at";
@ -140,7 +140,6 @@ class ClientePreciosModel extends \App\Models\BaseModel
$this->db
->table($this->table . " t1")
->where('cliente_id', $cliente_id)
->set('is_deleted', 1)
->set('deleted_at', $date_value)
->set('user_updated_id', $session->id_user)
->update();
@ -153,7 +152,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
// Se borran los valores existentes para todos los clientes en una sola consulta
$modelCliente = model('App\Models\Clientes\ClienteModel');
$clientes = $modelCliente->select('id')->where('is_deleted', 0)->findAll();
$clientes = $modelCliente->select('id')->where('deleted_at', null)->findAll();
// Se borra la tabla
$this->db->table($this->table)->truncate();
@ -288,7 +287,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
->table($this->table . " t1")
->select("t1.cliente_id AS id")
->where('t1.plantilla_id', $plantilla_id)
->where('t1.is_deleted', 0)
->where('t1.deleted_at', null)
->distinct()
->get()->getResultArray();
// Extraer solo los IDs de los clientes
@ -359,7 +358,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
->where('tipo_impresion', $config->tipo_impresion)
->where('tiempo_min <=', $tiempo)
->where('tiempo_max >=', $tiempo)
->where('is_deleted', 0)
->where('deleted_at', null)
->get()->getResultObject();
if (count($values) > 0) {
@ -389,7 +388,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
$builder->join("users t2", "t1.user_updated_id = t2.id", "left");
$builder->where('t1.is_deleted', 0);
$builder->where('t1.deleted_at', 0);
$builder->where('t1.cliente_id', $cliente_id);
if (empty($search))
@ -415,7 +414,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
"t1.plantilla_id AS id, t2.nombre AS nombre"
);
$builder->where('t1.is_deleted', 0);
$builder->where('t1.deleted_at', null);
$builder->where('t1.cliente_id', $cliente_id);
$builder->join("cliente_plantilla_precios t2", "t1.plantilla_id = t2.id", "left");
$builder->limit(1);
@ -442,7 +441,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
$rows = $this->db
->table($this->table)
->select("id, tiempo_min, tiempo_max")
->where("is_deleted", 0)
->where("deleted_at", null)
->where("tipo", $data["tipo"])
->where("tipo_maquina", $data["tipo_maquina"])
->where("tipo_impresion", $data["tipo_impresion"])
@ -476,7 +475,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
$value = $this->db
->table($this->table)
->select("plantilla_id")
->where("is_deleted", 0)
->where("deleted_at", null)
->where("cliente_id", $cliente_id)
->limit(1)->get()->getResultObject();