From 5f0416c178bff1dbda135141de2fe568bfd0edf8 Mon Sep 17 00:00:00 2001 From: lizandrogd <77708265+lizandrogd@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:11:57 -0500 Subject: [PATCH] u --- app/Http/Livewire/ShowPromociones.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/Http/Livewire/ShowPromociones.php b/app/Http/Livewire/ShowPromociones.php index 4b312bf..bc7aec3 100644 --- a/app/Http/Livewire/ShowPromociones.php +++ b/app/Http/Livewire/ShowPromociones.php @@ -316,6 +316,25 @@ class ShowPromociones extends Component 'confirmButtonText' => 'Sí, comprar.', ]); } + }else{ + + + $descuento = Saldo::where('usuario_id', Auth::user()->id)->first(); + $saldo_anterior = $descuento->valor; + $nuevo_saldo = $saldo_anterior - ($this->precioAhora *$this->cantidad_comprarPromo); + $cobro = $descuento->update(['valor' => $nuevo_saldo]); + //dd($cobro); + if ($cobro) { + $historial->update(['estado' => 'activo']); + $this->modalComprarPromo = false; + $this->credenciales($historial); + + } else { + $eliminar = Historial_cuenta::whereIn('id',$this->n)->delete(); + //dd($eliminar); + $this->alert('warning', 'Error en el cobro, comuniquese con soporte!', [ + 'position' => 'top']); + } } }