channelManager->find($request->appId, $request->channelName); if (is_null($channel)) { throw new HttpException(404, 'Unknown channel "'.$request->channelName.'"'); } if (! $channel instanceof PresenceChannel) { throw new HttpException(400, 'Invalid presence channel "'.$request->channelName.'"'); } $users = $channel->getUsers($request->appId); if ($users instanceof PromiseInterface) { return $users->then(function (array $users) { return $this->collectUsers($users); }); } return $this->collectUsers($users); } protected function collectUsers(array $users) { return [ 'users' => Collection::make($users)->map(function ($user) { return ['id' => $user->user_id]; })->values(), ]; } }