diff --git a/app/Http/Livewire/ShowPromociones.php b/app/Http/Livewire/ShowPromociones.php index 3fca004..5b7ec62 100755 --- a/app/Http/Livewire/ShowPromociones.php +++ b/app/Http/Livewire/ShowPromociones.php @@ -104,7 +104,7 @@ class ShowPromociones extends Component 'nombre_comprarPromo' => 'required', 'celular_comprarPromo' => 'required', 'email_comprarPromo' => 'required', - 'cantidad_comprarPromo' => 'required', + 'cantidad_comprarPromo' => 'required|numeric|min:1', ]; public function render() @@ -207,9 +207,22 @@ class ShowPromociones extends Component public function pagar() { - $this->validate(); + if ($this->cantidad_comprarPromo == 0){ + $this->alert('error', 'La cantidad debe ser mayor a 0', [ + 'position' => 'top' + ]); + return; + } + + if (auth()->user()->saldo->valor < $this->precioAhora * $this->cantidad_comprarPromo) { + $this->alert('error', 'Saldo insuficiente', [ + 'position' => 'top' + ]); + return; + } + $usuario_existe = User::firstWhere('email', $this->email_comprarPromo)->id ?? null; if (is_null($usuario_existe)) { diff --git a/resources/views/livewire/show-promociones.blade.php b/resources/views/livewire/show-promociones.blade.php index 6baa334..393b7ff 100755 --- a/resources/views/livewire/show-promociones.blade.php +++ b/resources/views/livewire/show-promociones.blade.php @@ -448,7 +448,7 @@ -
@@ -456,7 +456,7 @@ @if ($categoria_photo) @endif - +
@@ -808,10 +808,10 @@ @error('cantidad_comprarPromo') - Requerido* + Requerido* @enderror @@ -1037,13 +1037,13 @@ @endswitch @endif @endif -@endforeach +@endforeach *Usuario:* {{ $cuenta->correo }} *ContraseƱa:* {{ $cuenta->password }} @endif @endforeach - +