diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index 4df3285..dd2f0d7 100755 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -183,7 +183,7 @@ class ShowPlanes extends Component $this->searchTerm = $this->selectedOption; } } else { - $this->selectedOption = null; + $this->selectedOption = null; } $this->cont = $consulta_cuentas->toArray(); @@ -213,8 +213,8 @@ class ShowPlanes extends Component $this->password_renovar = $renovarCuenta->password; $this->fecha_inicial_renovar_old = $renovarCuenta->inicio; $this->fecha_inicial_renovar = $renovarCuenta->inicio; - $this->fecha_final_renovar_old = $renovarCuenta->vencimiento; - $this->fecha_final_renovar = $renovarCuenta->vencimiento; + $this->fecha_final_renovar_old = $renovarCuenta->vencimiento; + $this->fecha_final_renovar = $renovarCuenta->vencimiento; $this->estado = $renovarCuenta->estado; $this->renovar = true; @@ -230,7 +230,8 @@ class ShowPlanes extends Component public function getListeners() { return [ - 'siRenovar', 'noRenovar', + 'siRenovar', + 'noRenovar', ]; } public function saveRenovar() @@ -280,11 +281,19 @@ class ShowPlanes extends Component $id = $this->id_cuentaVer; $historial = Historial_cuenta::where('cuenta_id', $id)->first(); - //dd($historial); - $consultaFechaFinal = Historiale::find($historial->historial_id)->fecha_final; + if ($historial) { + $consultaFechaFinal = Historiale::find($historial->historial_id)->fecha_final; - //dd($consultaFechaFinal); - $nuevaFecha= $consultaFechaFinal->addDays($this->tiempo_usuario); + // Convertir cadena a objeto fecha usando Carbon + $consultaFechaFinal = \Carbon\Carbon::parse($consultaFechaFinal); + + // Ahora puedes realizar operaciones con fechas + $nuevaFecha = $consultaFechaFinal->addDays($this->tiempo_usuario); + } else { + $this->alert('warning', 'Error en el proceso de renovación. ', [ + 'position' => 'top' + ]); + } Historiale::where('id', $historial->historial_id)->update([ 'fecha_final' => date('Y-m-d', strtotime(strval($nuevaFecha))), @@ -304,7 +313,7 @@ class ShowPlanes extends Component Log_historial::create([ 'user_id' => Auth::user()->id, - 'detalle' => 'El usuario ha 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!', [ @@ -484,7 +493,7 @@ class ShowPlanes extends Component Log_historial::create([ 'user_id' => Auth::user()->id, - 'detalle' => 'El usuario ha eliminado la cuenta ' . $cuenta->correo . ' nota de eliminacion: ' . $this->nota_eliminacion + 'detalle' => 'El usuario ha eliminado la cuenta ' . $cuenta->correo . ' nota de eliminacion: ' . $this->nota_eliminacion ]); $cuenta->delete(); @@ -513,7 +522,7 @@ class ShowPlanes extends Component foreach ($cuentas as $cuenta) { Log_historial::create([ 'user_id' => Auth::user()->id, - 'detalle' => 'El usuario ha eliminado la cuenta ' . $cuenta->correo . ' nota de eliminacion: ' . $this->nota_eliminacion + 'detalle' => 'El usuario ha eliminado la cuenta ' . $cuenta->correo . ' nota de eliminacion: ' . $this->nota_eliminacion ]); } } @@ -663,7 +672,7 @@ class ShowPlanes extends Component for ($i = 0; $i < $perfiles; $i++) { $historial_cuenta = new Historial_cuenta; - $historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id; + $historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id; $historial_cuenta->historial_id = $historial->id; $historial_cuenta->perfil = $i + 1; $historial_cuenta->save(); @@ -674,7 +683,7 @@ class ShowPlanes extends Component ]); $this->addUser = false; - $this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first(); + $this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first(); } if ($this->consulta_verUsuarios->estado == 'activo') { // pantallas @@ -683,7 +692,7 @@ class ShowPlanes extends Component if ($consultaHC) { if ($consultaHC < $perfiles) { $historial_cuenta = new Historial_cuenta; - $historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id; + $historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id; $historial_cuenta->historial_id = $historial->id; $historial_cuenta->perfil = $consultaHC + 1; $historial_cuenta->save(); @@ -693,7 +702,7 @@ class ShowPlanes extends Component ]); $this->addUser = false; - $this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first(); + $this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first(); } else { $historial->delete(); $this->alert('warning', 'Ya haz alcanzado el maximo de perfiles!', [ @@ -702,7 +711,7 @@ class ShowPlanes extends Component } } else { $historial_cuenta = new Historial_cuenta; - $historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id; + $historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id; $historial_cuenta->historial_id = $historial->id; $historial_cuenta->perfil = $consultaHC + 1; $historial_cuenta->save(); @@ -719,7 +728,7 @@ class ShowPlanes extends Component $logsGeneral->save(); $this->addUser = false; - $this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first(); + $this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first(); } }