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.
This commit is contained in:
@@ -134,12 +134,15 @@ class ShowTarifas extends Component
|
||||
'rol_id.required' => 'El campo rol es obligatorio',
|
||||
]);
|
||||
|
||||
|
||||
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([
|
||||
'pantallas' => $planSeleccionado['pantallas'],
|
||||
@@ -186,12 +189,14 @@ class ShowTarifas extends Component
|
||||
'rol_id.required' => 'El campo rol es obligatorio',
|
||||
]);
|
||||
|
||||
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([
|
||||
'utilidad' => $this->utilidad,
|
||||
@@ -283,12 +288,14 @@ class ShowTarifas extends Component
|
||||
'rol_id.required' => 'El campo rol es obligatorio',
|
||||
]);
|
||||
|
||||
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([
|
||||
'valor' => $this->precio,
|
||||
@@ -326,12 +333,14 @@ class ShowTarifas extends Component
|
||||
'rol_id.required' => 'El campo rol es obligatorio',
|
||||
]);
|
||||
|
||||
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([
|
||||
'precio' => $this->precio,
|
||||
|
||||
@@ -575,12 +575,14 @@ class ShowUsuarios extends Component
|
||||
->exists();
|
||||
|
||||
|
||||
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) {
|
||||
$this->alert('warning', '¡Este usuario ya tiene esta tarifa!', [
|
||||
|
||||
Reference in New Issue
Block a user