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:
Juan Felipe Duarte
2025-10-16 11:49:20 -05:00
parent b034515908
commit 8c50434f31
2 changed files with 37 additions and 26 deletions
+29 -20
View File
@@ -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([
+8 -6
View File
@@ -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) {