mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
error presupuestos
This commit is contained in:
@ -10,7 +10,7 @@ class ErrorPresupuesto extends Model
|
||||
protected $table = 'presupuesto_errores';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
@ -20,6 +20,7 @@ class ErrorPresupuesto extends Model
|
||||
"datos_presupuesto",
|
||||
"visto",
|
||||
"last_user_id",
|
||||
"comment",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"deleted_at",
|
||||
@ -55,7 +56,7 @@ class ErrorPresupuesto extends Model
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
public function insertError(int $presupuesto_id,int $presupuesto_user_id,string $error,mixed $datos)
|
||||
public function insertError(int $presupuesto_id, int $presupuesto_user_id, string $error, mixed $datos)
|
||||
{
|
||||
$this->insert([
|
||||
"presupuesto_id" => $presupuesto_id,
|
||||
@ -63,24 +64,32 @@ class ErrorPresupuesto extends Model
|
||||
"error" => $error,
|
||||
"datos" => json_encode($datos)
|
||||
]);
|
||||
|
||||
}
|
||||
public function getQueryDatatable() : BaseBuilder
|
||||
public function updateComment(int $error_presupuesto_id, string $comment): bool
|
||||
{
|
||||
$updated = $this->update($error_presupuesto_id, [
|
||||
"comment" => $comment
|
||||
]);
|
||||
return $updated;
|
||||
}
|
||||
public function getQueryDatatable(): BaseBuilder
|
||||
{
|
||||
$query = $this->builder()
|
||||
->select([
|
||||
"presupuesto_errores.id",
|
||||
"CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser",
|
||||
"CONCAT(t2.first_name,' ',t2.last_name) as lastUser",
|
||||
"presupuestos.titulo as presupuestoTitulo",
|
||||
"presupuesto_errores.created_at",
|
||||
"presupuesto_errores.datos",
|
||||
"presupuesto_errores.visto",
|
||||
])
|
||||
->join("users t1","t1.id = presupuesto_errores.presupuesto_user_id","left")
|
||||
->join("users t2","t2.id = presupuesto_errores.last_user_id","left")
|
||||
->join("presupuestos","presupuestos.id = presupuesto_errores.presupuesto_id","left")
|
||||
->where("presupuesto_errores.deleted_at",null);
|
||||
->select([
|
||||
"presupuesto_errores.id",
|
||||
"presupuestos.id as presupuestoId",
|
||||
"CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser",
|
||||
"CONCAT(t2.first_name,' ',t2.last_name) as lastUser",
|
||||
"presupuesto_errores.created_at",
|
||||
"presupuesto_errores.datos",
|
||||
"presupuesto_errores.visto",
|
||||
"presupuesto_errores.comment",
|
||||
|
||||
])
|
||||
->join("users t1", "t1.id = presupuesto_errores.presupuesto_user_id", "left")
|
||||
->join("users t2", "t2.id = presupuesto_errores.last_user_id", "left")
|
||||
->join("presupuestos", "presupuestos.id = presupuesto_errores.presupuesto_id", "left")
|
||||
->where("presupuesto_errores.deleted_at", null);
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user