From c0e3284c628a7dcfbe574441267911af2e6be850 Mon Sep 17 00:00:00 2001 From: lizandrogd <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 27 Feb 2025 15:19:52 -0500 Subject: [PATCH] historial_id --- app/Http/Controllers/MenuController.php | 1 + app/Http/Livewire/Bell.php | 3 +- app/Http/Livewire/ShowPlanes.php | 5 +++ app/Http/Livewire/ShowPromociones.php | 4 +++ app/Http/Livewire/ShowServicios.php | 4 +++ app/Http/Livewire/ShowTop.php | 3 +- app/Http/Livewire/ShowUsuarios.php | 3 ++ app/Imports/UsersImport.php | 1 + ...151740_add_historial_id_to_log_general.php | 32 +++++++++++++++++++ 9 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2025_02_27_151740_add_historial_id_to_log_general.php diff --git a/app/Http/Controllers/MenuController.php b/app/Http/Controllers/MenuController.php index 8205f9f..ff602e1 100755 --- a/app/Http/Controllers/MenuController.php +++ b/app/Http/Controllers/MenuController.php @@ -160,6 +160,7 @@ class MenuController extends Controller $logsGeneral->user_id = $consulta_recarga->usuario_id; $logsGeneral->detalle = 'El usuario '.$nombre.' - '.$email.'ha recargador por MP el monto de ' . $monto . ', Nuevo saldo disponible: $'.$nuevo_saldo; $logsGeneral->tipo = 'recarga'; + $logsGeneral->historial_id = null; $logsGeneral->save(); } diff --git a/app/Http/Livewire/Bell.php b/app/Http/Livewire/Bell.php index 6cde1b5..3917afd 100755 --- a/app/Http/Livewire/Bell.php +++ b/app/Http/Livewire/Bell.php @@ -78,7 +78,8 @@ class Bell extends Component Log_general::create([ 'user_id' => Auth::user()->id, 'detalle' => 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha reclamado el premio de $' . $notificacion->premio, - 'tipo' => 'premio' + 'tipo' => 'premio', + 'historial_id' => null ]); $this->reclamandoPremio = false; diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index 8d5f46a..912c255 100755 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -348,6 +348,7 @@ class ShowPlanes extends Component $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->tipo = 'asigno_cuenta'; + $logsGeneral->historial_id= $historial_cuenta->historial_id; $logsGeneral->save(); } } @@ -419,6 +420,7 @@ class ShowPlanes extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha renovado el servicio:' . $servicioNombre . ' con cuenta ' . $cuenta->correo . ' para el cliente: ' . $historial->cliente->name . ' - ' . $historial->cliente->email; $logsGeneral->tipo = 'renovo_cuenta'; + $logsGeneral->historial_id = $historial_guardar->id; $logsGeneral->save(); } } @@ -496,6 +498,7 @@ class ShowPlanes extends Component $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->tipo = 'asigno_cuenta'; + $logsGeneral->historial_id = $historial_cuenta->historial_id; $logsGeneral->save(); } @@ -819,6 +822,8 @@ class ShowPlanes extends Component $logsGeneral = new Log_general(); $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha añadido el usuario ' . $this->searchTerm . ' a una cuenta '; + $logsGeneral->tipo = 'asignar_cuenta'; + $logsGeneral->historial_id = $historial->id; // . ' a la cuenta ' . $this->consulta_verUsuarios->name . ' - ' . $this->consulta_verUsuarios->email; $logsGeneral->save(); diff --git a/app/Http/Livewire/ShowPromociones.php b/app/Http/Livewire/ShowPromociones.php index 44a906b..3c61994 100755 --- a/app/Http/Livewire/ShowPromociones.php +++ b/app/Http/Livewire/ShowPromociones.php @@ -365,6 +365,7 @@ class ShowPromociones extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha comprado la promocion ' . $this->consulta->nombre . ' - ' . $this->consulta->descripcion . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor .', Saldo anterior: $'.$saldo_anterior.', Nuevo saldo disponible: $'.$nuevo_saldo; $logsGeneral->tipo = 'compra'; + $logsGeneral->historial_id = $historial->id; $logsGeneral->save(); $this->modalComprarPromo = false; @@ -406,6 +407,7 @@ class ShowPromociones extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha comprado la promocion ' . $this->consulta->nombre . ' - ' . $this->consulta->descripcion . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor ?? '' . ' y algunos han quedado pendientes'.', Saldo anterior: $'.$saldo_anterior.', Nuevo saldo disponible: $'.$nuevo_saldo; $logsGeneral->tipo = 'compra'; + $logsGeneral->historial_id = $this->historial->id; $logsGeneral->save(); $this->credenciales($this->historial); @@ -415,6 +417,7 @@ class ShowPromociones extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' Tuvo error en el cobro, Comprando la promoción ' . $this->consulta->nombre . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor .' No se desconto el saldo, ni se asignaron cuentas.'; $logsGeneral->tipo = 'compra_error'; + $logsGeneral->historial_id = $this->historial->id; $logsGeneral->save(); $this->alert('warning', 'Error en el cobro, comuniquese con soporte!', [ 'position' => 'top' @@ -438,6 +441,7 @@ class ShowPromociones extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' Cancelo la compra del plan ' . $this->consulta->nombre . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor.' No se desconto el saldo, ni se asignaron cuentas.'; $logsGeneral->tipo = 'compra_cancelada'; + $logsGeneral->historial_id = $this->historial->id; $logsGeneral->save(); $this->alert('success', 'Compra cancelada!', [ 'position' => 'top' diff --git a/app/Http/Livewire/ShowServicios.php b/app/Http/Livewire/ShowServicios.php index b457a1e..fa8b7b7 100755 --- a/app/Http/Livewire/ShowServicios.php +++ b/app/Http/Livewire/ShowServicios.php @@ -406,6 +406,7 @@ class ShowServicios extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' Tuvo error de "No hay cuentas disponibles" Comprando el servicio ' . $servicioNombre . ' - ' . $cuentasMostar . ' cantidad de ' . $this->cantidad_tarjetaPlan . ' por un valor de $' . $total_valor . ' Se desligaron todas las cuentas.'; $logsGeneral->tipo = 'compra_error'; + $logsGeneral->historial_id= $historial->id; $logsGeneral->save(); $this->alert('warning', 'No hay cuentas disponibles!', [ 'position' => 'top' @@ -426,6 +427,7 @@ class ShowServicios extends Component $logsGeneral = new Log_general(); $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha comprado el servicio ' . $servicioNombre . ' - ' . $cuentasMostar . ' cantidad de ' . $this->cantidad_tarjetaPlan . ' por un valor de $' . $total_valor . ', Saldo anterior: $' . $saldo_anterior . ', Nuevo saldo disponible: $' . $nuevo_saldo; + $logsGeneral->historial_id= $historial->id; $logsGeneral->tipo = 'compra'; $logsGeneral->save(); @@ -438,6 +440,7 @@ class ShowServicios extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' Tuvo un error con el cobro del servicio ' . $servicioNombre . ' - ' . $cuentasMostar . ' cantidad de ' . $this->cantidad_tarjetaPlan . ' por un valor de $' . $total_valor; $logsGeneral->tipo = 'compra_error'; + $logsGeneral->historial_id= $historial->id; $logsGeneral->save(); $eliminar = Historial_cuenta::where('historial_id', $historial->id)->delete(); $this->alert('warning', 'Error en el cobro, comuniquese con soporte!', [ @@ -452,6 +455,7 @@ class ShowServicios extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' Tuvo error de "No hay cuentas disponibles" Comprando el servicio ' . $servicioNombre . ' - ' . $cuentasMostar . ' cantidad de ' . $this->cantidad_tarjetaPlan . ' por un valor de $' . $total_valor . ' No se desconto el saldo, ni se asignaron cuentas.'; $logsGeneral->tipo = 'compra_error'; + $logsGeneral->historial_id= $historial->id; $logsGeneral->save(); $this->alert('warning', 'No hay cuentas disponibles!', [ 'position' => 'top' diff --git a/app/Http/Livewire/ShowTop.php b/app/Http/Livewire/ShowTop.php index dfea3ef..925e8dc 100755 --- a/app/Http/Livewire/ShowTop.php +++ b/app/Http/Livewire/ShowTop.php @@ -93,7 +93,8 @@ class ShowTop extends Component Log_general::create([ 'user_id' => Auth::user()->id, 'detalle' => 'El usuario ' . Auth::user()->name . ' ha entregado el premio ' . $premio . ' para el usuario: ' . $vendedor->name . ' - ' . $vendedor->email, - 'tipo' => 'premio' + 'tipo' => 'premio', + 'historial_id' => null ]); } diff --git a/app/Http/Livewire/ShowUsuarios.php b/app/Http/Livewire/ShowUsuarios.php index 97f98f0..8194636 100755 --- a/app/Http/Livewire/ShowUsuarios.php +++ b/app/Http/Livewire/ShowUsuarios.php @@ -267,6 +267,7 @@ class ShowUsuarios extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha recargado a ' . $nombre . ' - ' . $email . ' la cantidad de $' . $this->valor_recargar . ', Saldo anterior: $' . $this->saldo_actual . ', Nuevo saldo disponible: $' . $nuevo_saldo; $logsGeneral->tipo = 'recarga'; + $logsGeneral->historial_id = null; $logsGeneral->save(); $this->alert('success', 'Saldo actualizado con exito!', [ @@ -302,6 +303,7 @@ class ShowUsuarios extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha descontado la cantidad de $' . $this->valor_recargar . ' al usuario ' . $userSaldo->name . ' - ' . $userSaldo->email; $logsGeneral->tipo = 'descuento_saldo'; + $logsGeneral->historial_id = null; $logsGeneral->save(); @@ -572,6 +574,7 @@ class ShowUsuarios extends Component $logsGeneral->user_id = Auth::user()->id; $logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha eliminado al usuario ' . $user->name . ' - ' . $user->email; $logsGeneral->tipo = 'eliminar_usuario'; + $logsGeneral->historial_id = null; $logsGeneral->save(); $user->delete(); diff --git a/app/Imports/UsersImport.php b/app/Imports/UsersImport.php index 7aaa94d..2eaca62 100755 --- a/app/Imports/UsersImport.php +++ b/app/Imports/UsersImport.php @@ -67,6 +67,7 @@ class UsersImport implements ToModel $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->tipo = 'asigno_cuenta'; + $logsGeneral->historial_id = $cuentaPendiente->historial_id; $logsGeneral->save(); } } diff --git a/database/migrations/2025_02_27_151740_add_historial_id_to_log_general.php b/database/migrations/2025_02_27_151740_add_historial_id_to_log_general.php new file mode 100644 index 0000000..5c27d9d --- /dev/null +++ b/database/migrations/2025_02_27_151740_add_historial_id_to_log_general.php @@ -0,0 +1,32 @@ +string('historial_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('log_general', function (Blueprint $table) { + $table->dropColumn('historial_id'); + }); + } +};