From 89841e639544d5f5560b5c986ae1616623bac507 Mon Sep 17 00:00:00 2001 From: lizandrogd <77708265+lizandrogd@users.noreply.github.com> Date: Sun, 28 Jul 2024 17:25:46 -0500 Subject: [PATCH] Update ShowPlanes.php --- app/Http/Livewire/ShowPlanes.php | 82 ++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index 8cc2eaa..80552d8 100755 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -238,46 +238,56 @@ class ShowPlanes extends Component } public function saveRenovar() { - if ($this->fecha_inicial_renovar_old !== $this->fecha_inicial_renovar || $this->fecha_final_renovar_old !== $this->fecha_final_renovar) { - $this->alert('warning', '¿Desea también desvincular todos los usuarios de esta cuenta? ', [ - 'position' => 'center', - 'timer' => '60000', - 'toast' => false, - 'text' => 'Esta seguro', - 'timerProgressBar' => true, - 'showDenyButton' => true, - 'onDenied' => 'noRenovar', - 'denyButtonText' => 'No, solo renovar', - 'showConfirmButton' => true, - 'onConfirmed' => 'siRenovar', - 'confirmButtonText' => 'Si, liberar cuenta', - 'customClass' => [ - 'confirmButton' => 'bg-green-500', - 'denyButton' => 'bg-red-500', - ] - ]); - } else { - $cuenta_renovar = Cuentas::find($this->id_cuentaVer); - - Cuentas::where('id', $this->id_cuentaVer)->update([ - 'correo' => $this->usuario_renovar, - 'password' => $this->password_renovar, - 'estado' => $this->estado, - ]); - - if ($this->usuario_renovar_old !== $this->usuario_renovar) { - Log_historial::create([ - 'user_id' => Auth::user()->id, - 'detalle' => 'El usuario ha editado el usuario de la cuenta ' . $cuenta_renovar->correo + $correo_existe = Cuentas::where('correo', $this->usuario_renovar)->exists(); + if (!$correo_existe) { + if ($this->fecha_inicial_renovar_old !== $this->fecha_inicial_renovar || $this->fecha_final_renovar_old !== $this->fecha_final_renovar) { + $this->alert('warning', '¿Desea también desvincular todos los usuarios de esta cuenta? ', [ + 'position' => 'center', + 'timer' => '60000', + 'toast' => false, + 'text' => 'Esta seguro', + 'timerProgressBar' => true, + 'showDenyButton' => true, + 'onDenied' => 'noRenovar', + 'denyButtonText' => 'No, solo renovar', + 'showConfirmButton' => true, + 'onConfirmed' => 'siRenovar', + 'confirmButtonText' => 'Si, liberar cuenta', + 'customClass' => [ + 'confirmButton' => 'bg-green-500', + 'denyButton' => 'bg-red-500', + ] ]); - } + } else { + $cuenta_renovar = Cuentas::find($this->id_cuentaVer); - $this->alert('success', 'Cuenta actualizada correctamente!', [ + Cuentas::where('id', $this->id_cuentaVer)->update([ + 'correo' => $this->usuario_renovar, + 'password' => $this->password_renovar, + 'estado' => $this->estado, + ]); + + if ($this->usuario_renovar_old !== $this->usuario_renovar) { + Log_historial::create([ + 'user_id' => Auth::user()->id, + 'detalle' => 'El usuario ha editado el usuario de la cuenta ' . $cuenta_renovar->correo + ]); + } + $this->alert('success', 'Cuenta actualizada correctamente!', [ + 'position' => 'top' + ]); + + + + + + $this->renovar = false; + $this->ver = false; + } + } else { + $this->alert('warning', 'Esta cuenta ya existe!', [ 'position' => 'top' ]); - - $this->renovar = false; - $this->ver = false; } } public function siRenovar()