From 2b0d1b48e7331cc259e86a0547da9122246e2ada Mon Sep 17 00:00:00 2001 From: Felipe Date: Wed, 20 Mar 2024 10:33:19 -0500 Subject: [PATCH] log con filtro y solo cuando editen el usuario --- app/Http/Livewire/ShowLogHistorial.php | 5 ++++ app/Http/Livewire/ShowPlanes.php | 28 +++++++++++++++---- .../livewire/show-log-historial.blade.php | 23 +++++++-------- .../views/livewire/show-planes.blade.php | 14 ++++++---- 4 files changed, 48 insertions(+), 22 deletions(-) diff --git a/app/Http/Livewire/ShowLogHistorial.php b/app/Http/Livewire/ShowLogHistorial.php index 0a87003..7791c52 100644 --- a/app/Http/Livewire/ShowLogHistorial.php +++ b/app/Http/Livewire/ShowLogHistorial.php @@ -14,6 +14,7 @@ class ShowLogHistorial extends Component public $entradas; public $buscar; + public $tipo; public $filtro_fecha; public $user_id; @@ -32,6 +33,10 @@ class ShowLogHistorial extends Component } + if ($this->tipo) { + $query->where('detalle', 'like', '%' . $this->tipo . '%'); + } + if ($this->filtro_fecha) { $query->whereDate('created_at', $this->filtro_fecha); } diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index aedafbd..e86b079 100755 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -77,6 +77,7 @@ class ShowPlanes extends Component public $usuario_renovar; + public $usuario_renovar_old; public $password_renovar; public $fecha_inicial_renovar; public $fecha_inicial_renovar_old; @@ -211,6 +212,7 @@ class ShowPlanes extends Component $id = $this->id_cuentaVer; $renovarCuenta = Cuentas::findOrFail($id); + $this->usuario_renovar_old = $renovarCuenta->correo; $this->usuario_renovar = $renovarCuenta->correo; $this->password_renovar = $renovarCuenta->password; $this->fecha_inicial_renovar_old = $renovarCuenta->inicio; @@ -250,10 +252,12 @@ class ShowPlanes extends Component 'estado' => $this->estado, ]); - Log_historial::create([ - 'user_id' => Auth::user()->id, - 'detalle' => 'El usuario ha editado la cuenta ' . $cuenta_renovar->correo - ]); + 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' @@ -281,7 +285,7 @@ class ShowPlanes extends Component Log_historial::create([ 'user_id' => Auth::user()->id, - 'detalle' => 'El usuario ha editado, renovado y liberado la cuenta ' . $cuenta_renovar->correo + 'detalle' => 'El usuario ha renovado y liberado la cuenta ' . $cuenta_renovar->correo ]); $this->alert('success', 'Cuenta renovada y liberada correctamente!', [ @@ -307,7 +311,7 @@ class ShowPlanes extends Component Log_historial::create([ 'user_id' => Auth::user()->id, - 'detalle' => 'El usuario ha editado y renovado la cuenta ' . $cuenta_renovar->correo + 'detalle' => 'El usuario ha renovado la cuenta ' . $cuenta_renovar->correo ]); $this->alert('success', 'Cuenta renovada correctamente!', [ @@ -443,6 +447,12 @@ class ShowPlanes extends Component public function confirm_delete_cuenta() { + $this->validate([ + 'nota_eliminacion' => 'required', + ],[ + 'nota_eliminacion.required' => 'La nota es obligatoria', + ]); + $cuenta = Cuentas::findOrFail($this->delete_cuenta); Log_historial::create([ @@ -465,6 +475,12 @@ class ShowPlanes extends Component public function confirm_delete_cuentas() { + $this->validate([ + 'nota_eliminacion' => 'required', + ],[ + 'nota_eliminacion.required' => 'La nota es obligatoria', + ]); + $cuentas = Cuentas::whereIn('id', $this->delete_1)->get(); if ($cuentas) { forEach ($cuentas as $cuenta) { diff --git a/resources/views/livewire/show-log-historial.blade.php b/resources/views/livewire/show-log-historial.blade.php index bb1def8..3bd61d2 100644 --- a/resources/views/livewire/show-log-historial.blade.php +++ b/resources/views/livewire/show-log-historial.blade.php @@ -1,25 +1,26 @@
-
+
Log historial
- - +
+ + + @error('nota_eliminacion') +
{{ $message }}
+ @enderror
@@ -1053,8 +1054,11 @@
+ @error('nota_eliminacion') +
{{ $message }}
+ @enderror