user()->role != 1) { // $this->alert('error', 'Unauthorized access.'); // return redirect('/'); // Adjust redirect as needed // } $this->fetchNotifications(); } public function fetchNotifications() { try { $this->updating = true; $response = Http::get('https://api.example.com/notification'); if ($response->successful()) { $this->notifications = $response->json()['data'] ?? []; } else { $this->alert('error', 'Failed to fetch notifications.'); } } catch (\Exception $e) { $this->alert('error', 'An error occurred: ' . $e->getMessage()); } finally { $this->updating = false; } } public function render() { return view('livewire.notifications.notification-list')->layout('layouts.app', ['title' => 'Notifications']); } }