From 10678aa4ff815b0e39f2a258957a6fa5bc77925a Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 10 Oct 2024 16:08:50 -0500 Subject: [PATCH] update --- app/Http/Livewire/ShowPlanes.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index 0defcf1..a7b9d45 100755 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -331,7 +331,7 @@ class ShowPlanes extends Component $historial_cuenta->save(); $cuentaPendiente->update(['estado' => 'cerrado']); - if ($cuentaPendiente->historial->vendedor !== null) { + if ($cuentaPendiente->historial?->vendedor !== null) { $cuentaPendiente->historial->vendedor->notify(new NotificacionPendiente($servicioName)); } @@ -476,23 +476,26 @@ class ShowPlanes extends Component $historial_cuenta->save(); $cuentaPendiente->update(['estado' => 'cerrado']); - if ($cuentaPendiente->historial->vendedor !== null) { + if ($cuentaPendiente->historial?->vendedor !== null) { $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 = new Notificacion(); + $consulta->remitente_id = Auth::user()->id; + $consulta->destinatario_id = $historial_cuenta->historial?->vendedor_id ?? null; + $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(); - $logsGeneral = new Log_general(); - $logsGeneral->user_id = $historial_cuenta->historial->vendedor_id; - $logsGeneral->detalle = 'Se asigno una cuenta ' . $servicioName . ', con credenciales: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password . ' Que se encontraba en estado pendiente'; - $logsGeneral->save(); + if ($cuentaPendiente->historial?->vendedor !== null) { + $logsGeneral = new Log_general(); + $logsGeneral->user_id = $historial_cuenta->historial->vendedor_id; + $logsGeneral->detalle = 'Se asigno una cuenta ' . $servicioName . ', con credenciales: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password . ' Que se encontraba en estado pendiente'; + $logsGeneral->save(); + } + } }