/** * Refreshes a user, or all users, Steam data * @param type $id * @return json */ public function refresh($id = null) { // If a specific user has been refreshed if (!is_null($id)) { $data = Input::all(); try { $steamObject = new SteamId($data['community_id']); $update = ['nickname' => $steamObject->getNickname(), 'avatar' => $steamObject->getMediumAvatarUrl()]; $this->users->edit($data['id'], $update); } catch (Exception $e) { return $this->jsonResponse(400, false, $e->getMessage()); } return $this->jsonResponse(200, true, 'User details refreshed!', $this->users->getWithRoles($data['id'])); } else { $users = $this->users->getAll(); try { foreach ($users as $user) { $steamObject = new SteamId($user['community_id']); $update = ['nickname' => $steamObject->getNickname(), 'avatar' => $steamObject->getMediumAvatarUrl()]; $this->users->edit($user['id'], $update); } } catch (Exception $e) { return $this->jsonResponse(400, false, $e->getMessage()); } return $this->jsonResponse(200, true, 'The users have been updated!', $this->users->getWithRoles()); } }