guard = $guard; $this->showCount = $showCount; $this->showAvatars = $showAvatars; $this->maxDisplay = $maxDisplay; $this->loadOnlineUsers(); } public function loadOnlineUsers() { try { $presenceService = app(PresenceService::class); $users = $presenceService->getOnlineUsers($this->guard); // Limit the display count $this->onlineUsers = $users->take($this->maxDisplay)->toArray(); $this->dispatch('users-online-updated', [ 'count' => $users->count(), 'users' => $this->onlineUsers ]); } catch (\Exception $e) { $this->onlineUsers = []; } } #[On('presence-updated')] public function refreshUsers() { $this->loadOnlineUsers(); } public function render() { return view('livewire.users-online'); } }