id = $id; // Placeholder role check // if (auth()->user()->role != 1) { // $this->alert('error', 'Unauthorized access.'); // return redirect('/member-management/lock-account'); // } $this->fetchAccount(); } public function fetchAccount() { try { $response = Http::get("https://api.example.com/member/{$this->id}"); if ($response->successful()) { $this->userInfo = $response->json()['data'] ?? null; } else { $this->alert('error', 'Failed to fetch account data.'); return redirect('/member-management/lock-account'); } } catch (\Exception $e) { $this->alert('error', 'An error occurred: ' . $e->getMessage()); return redirect('/member-management/lock-account'); } } public function activateAccount() { $this->loading = true; try { $response = Http::post("https://api.example.com/memberActivate/{$this->id}"); if ($response->successful()) { $this->alert('success', 'Record was successfully updated.'); return redirect('/member-management/lock-account'); } else { $this->alert('error', 'Failed to activate account.'); } } catch (\Exception $e) { $this->alert('error', 'An error occurred: ' . $e->getMessage()); } finally { $this->loading = false; } } public function render() { return view('livewire.member-management.lock-account-view')->layout('layouts.app', ['title' => 'Locked Account Details']); } }