/** * Registers a given player. * * @param Request $request * * @return Response */ public function registerPlayer(Request $request) { $data = $request->all(); $user = $this->usersRepository->addUser($data['email'], $data['name'], $data['password']); $player = $this->playersRepository->addPlayer($user, $user->name); return ['player' => $player->toArray()]; }
/** * Registers a new admin into the system. * * @param Request $request * * @return Response */ public function registerAdministrator(Request $request) { $data = $request->all(); // TODO: Validate the data. $user = $this->usersRepository->addUser($data['email'], $data['name'], $data['password']); $admin = $this->administratorsRepository->addAdministrator($user, $user->name); return ['administrator' => $admin->toArray()]; }
/** * Calls the repo add player method, * Passing the retrieved User. * * @param int $userID * @param string $nickname * * @throws Illuminate\Database\Eloquent\ModelNotFoundException * * @return Player */ public function addPlayer($userID, $nickname) { $user = $this->usersRepo->getUser($userID); return $this->playersRepo->addPlayer($user, $nickname); }