From 8c50434f318d390772258596354a2a7d58e3da9e Mon Sep 17 00:00:00 2001 From: Juan Felipe Duarte <70235683+DuarteJFelipe@users.noreply.github.com> Date: Thu, 16 Oct 2025 11:49:20 -0500 Subject: [PATCH] Restrict price validation to non-super users Updated price validation logic in ShowTarifas and ShowUsuarios to allow users with the 'super' role to set prices below the base value. Other users will continue to receive an error if the price is less than the base value. --- app/Http/Livewire/ShowTarifas.php | 49 ++++++++++++++++++------------ app/Http/Livewire/ShowUsuarios.php | 14 +++++---- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/app/Http/Livewire/ShowTarifas.php b/app/Http/Livewire/ShowTarifas.php index 8157bf7..16dbf7c 100644 --- a/app/Http/Livewire/ShowTarifas.php +++ b/app/Http/Livewire/ShowTarifas.php @@ -134,11 +134,14 @@ class ShowTarifas extends Component 'rol_id.required' => 'El campo rol es obligatorio', ]); - if ($this->precio < $this->valorBase) { - $this->alert('error', 'El precio no puede ser menor al costo del plan', [ - 'position' => 'top' - ]); - return; + + if (auth()->user()->rol->nombre !== 'super') { + if ($this->precio < $this->valorBase) { + $this->alert('error', 'El precio no puede ser menor al costo del plan', [ + 'position' => 'top' + ]); + return; + } } Tarifas::create([ @@ -186,11 +189,13 @@ class ShowTarifas extends Component 'rol_id.required' => 'El campo rol es obligatorio', ]); - if ($this->precio < $this->valorBase) { - $this->alert('error', 'El precio no puede ser menor al costo del plan', [ - 'position' => 'top' - ]); - return; + if (auth()->user()->rol->nombre !== 'super') { + if ($this->precio < $this->valorBase) { + $this->alert('error', 'El precio no puede ser menor al costo del plan', [ + 'position' => 'top' + ]); + return; + } } TarifaPromo::create([ @@ -283,11 +288,13 @@ class ShowTarifas extends Component 'rol_id.required' => 'El campo rol es obligatorio', ]); - if ($this->precio < $this->valorBase) { - $this->alert('error', 'El precio no puede ser menor al valor base', [ - 'position' => 'top' - ]); - return; + if (auth()->user()->rol->nombre !== 'super') { + if ($this->precio < $this->valorBase) { + $this->alert('error', 'El precio no puede ser menor al valor base', [ + 'position' => 'top' + ]); + return; + } } $tarifa->update([ @@ -326,11 +333,13 @@ class ShowTarifas extends Component 'rol_id.required' => 'El campo rol es obligatorio', ]); - if ($this->precio < $this->valorBase) { - $this->alert('error', 'El precio no puede ser menor al valor base', [ - 'position' => 'top' - ]); - return; + if (auth()->user()->rol->nombre !== 'super') { + if ($this->precio < $this->valorBase) { + $this->alert('error', 'El precio no puede ser menor al valor base', [ + 'position' => 'top' + ]); + return; + } } $tarifa->update([ diff --git a/app/Http/Livewire/ShowUsuarios.php b/app/Http/Livewire/ShowUsuarios.php index 18536c8..ffa6ca5 100755 --- a/app/Http/Livewire/ShowUsuarios.php +++ b/app/Http/Livewire/ShowUsuarios.php @@ -132,7 +132,7 @@ class ShowUsuarios extends Component } $consulta_usuarios = $consulta_usuarios - ->with('rol', 'saldo','subvendedor_relacion') + ->with('rol', 'saldo', 'subvendedor_relacion') ->orderBy('id', 'DESC') ->withCount('historiales_venta') ->paginate($this->entradas); @@ -575,11 +575,13 @@ class ShowUsuarios extends Component ->exists(); - if ($this->precioTarifasGestion < $this->valorBase) { - $this->alert('error', 'El precio no puede ser menor al costo del plan', [ - 'position' => 'top' - ]); - return; + if (auth()->user()->rol->nombre !== 'super') { + if ($this->precioTarifasGestion < $this->valorBase) { + $this->alert('error', 'El precio no puede ser menor al costo del plan', [ + 'position' => 'top' + ]); + return; + } } if ($consulta_existe) {