From 8f92b155be0d44dff804cf17be2857d98ce58b58 Mon Sep 17 00:00:00 2001 From: Felipe Date: Wed, 8 Nov 2023 17:24:20 -0500 Subject: [PATCH] pendientes fixed --- app/Http/Livewire/ShowPromociones.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/Http/Livewire/ShowPromociones.php b/app/Http/Livewire/ShowPromociones.php index bc7aec3..7418b50 100755 --- a/app/Http/Livewire/ShowPromociones.php +++ b/app/Http/Livewire/ShowPromociones.php @@ -317,21 +317,17 @@ class ShowPromociones extends Component ]); } }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']); } @@ -350,12 +346,15 @@ class ShowPromociones extends Component $this->modalComprarPromo = false; foreach ($this->f as $serviceId) { - $pendiente = new Pendientes(); - $pendiente->historial_id = $this->historial->id; - $pendiente->cantidad = $this->cantidad_comprarPromo; - $pendiente->estado = 'pendiente'; - $pendiente->servicio_id = $serviceId; - $pendiente->save(); + + for ($y = 0; $y < (int)$this->cantidad_comprarPromo; $y++) { + $pendiente = new Pendientes(); + $pendiente->historial_id = $this->historial->id; + $pendiente->cantidad = '1'; + $pendiente->estado = 'pendiente'; + $pendiente->servicio_id = $serviceId; + $pendiente->save(); + } } $this->credenciales($this->historial);