diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index ff79a79..c4f5bf3 100755 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -317,40 +317,40 @@ class ShowPlanes extends Component 'detalle' => 'El usuario ha renovado y liberado la cuenta ' . $cuenta_renovar->correo ]); - if ($this->estado === 'activo') { - $servicioPantallas = Servicio::find($this->servicio_newCuenta)->pantallas; + $servicio_id= $cuenta_renovar->servicio->id; + $servicioPantallas = Servicio::find($servicio_id)->pantallas; - $cuentasPendientes = Pendientes::where('estado', 'pendiente')->where('servicio_id', $this->servicio_newCuenta)->take($servicioPantallas)->get(); + $cuentasPendientes = Pendientes::where('estado', 'pendiente')->where('servicio_id', $servicio_id)->take($servicioPantallas)->get(); - foreach ($cuentasPendientes as $i => $cuentaPendiente) { - $servicioName = $cuentaPendiente->servicio->nombre; + foreach ($cuentasPendientes as $i => $cuentaPendiente) { + $servicioName = $cuentaPendiente->servicio->nombre; - $historial_cuenta = new Historial_cuenta(); - $historial_cuenta->historial_id = $cuentaPendiente->historial_id; - $historial_cuenta->cuenta_id = $id->id; - $historial_cuenta->perfil = $i + 1; - $historial_cuenta->save(); - $cuentaPendiente->update(['estado' => 'cerrado']); + $historial_cuenta = new Historial_cuenta(); + $historial_cuenta->historial_id = $cuentaPendiente->historial_id; + $historial_cuenta->cuenta_id = $id->id; + $historial_cuenta->perfil = $i + 1; + $historial_cuenta->save(); + $cuentaPendiente->update(['estado' => 'cerrado']); - $cuentaPendiente->historial->vendedor->notify(new NotificacionPendiente($servicioName)); + $cuentaPendiente->historial->vendedor->notify(new NotificacionPendiente($servicioName)); - $consulta = new Notificacion(); - $consulta->remitente_id = Auth::user()->id; - $consulta->destinatario_id = $historial_cuenta->historial->vendedor_id; - $consulta->titulo = "Licencia asignada para $servicioName"; - $consulta->descripcion = 'La licencia de ' . $servicioName . ' ha sido activada y ahora puedes utilizar tu cuenta sin problemas. Tus credenciales son: correo: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password; - $consulta->estado = true; - $consulta->todos = false; - $consulta->save(); - - Log_historial::create([ - 'user_id' => $historial_cuenta->historial->vendedor_id, - 'detalle' => 'La cuenta de ' . $servicioName . ' ha sido renovada y asignada desde pendiente, correo: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password . ', al usuario ' . $cuentaPendiente->historial->cliente->name, - ]); - } + $consulta = new Notificacion(); + $consulta->remitente_id = Auth::user()->id; + $consulta->destinatario_id = $historial_cuenta->historial->vendedor_id; + $consulta->titulo = "Licencia asignada para $servicioName"; + $consulta->descripcion = 'La licencia de ' . $servicioName . ' ha sido activada y ahora puedes utilizar tu cuenta sin problemas. Tus credenciales son: correo: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password; + $consulta->estado = true; + $consulta->todos = false; + $consulta->save(); + Log_historial::create([ + 'user_id' => $historial_cuenta->historial->vendedor_id, + 'detalle' => 'La cuenta de ' . $servicioName . ' ha sido renovada y asignada desde pendiente, correo: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password . ', al usuario ' . $cuentaPendiente->historial->cliente->name, + ]); } + + $this->alert('success', 'Cuenta renovada y liberada correctamente!', [ 'position' => 'top' ]);