userApiService->fetchUser($username, ['username', 'motto', 'look']); return response()->json(['data' => $user]); } public function userProfile(string $username): JsonResponse { $user = User::where('username', $username)->first(); if (! $user) { return response()->json(['data' => null], 404); } return response()->json([ 'data' => [ 'id' => $user->id, 'username' => $user->username, 'look' => $user->look, 'motto' => $user->motto, 'account_created' => $user->account_created, 'online' => false, ], ]); } public function onlineUsers(): JsonResponse { $users = $this->userApiService->onlineUsers(['username', 'motto', 'look'], true); return response()->json(['data' => $users]); } public function onlineUserCount(): JsonResponse { return response()->json([ 'data' => ['onlineCount' => $this->userApiService->onlineUserCount()], ]); } public function leaderboard(Request $request): JsonResponse { $type = $request->query('type', 'credits'); $limit = (int) $request->query('limit', 100); if (! in_array($type, ['credits', 'pixels'])) { $type = 'credits'; } $users = User::orderByDesc($type) ->limit($limit) ->get(['id', 'username', 'look', 'motto', 'credits', 'pixels']); return response()->json([ 'data' => LeaderboardUserResource::collection($users), 'type' => $type, ]); } }