public function view(UserRepositoryInterface $query, $request, $response) { $iduser = $request->getAttribute('iduser'); $data = $query->find($iduser); if (empty($data)) { throw new Exception('Could not find user #' . $iduser, 4); } Response::json($response, $data); }
/** * Edit a user * * @return json */ public function edit() { $data = Input::all(); // Check if user is trying to disable their own account if ($data['id'] == Auth::user()->id && $data['edit']['state'] == 0) { return $this->jsonResponse(400, false, 'You cannot disable your own account.'); } $user = $this->users->edit($data['id'], ['enabled' => $data['edit']['state']]); $roles = $this->roles->getBy('name', 'guest', '!='); foreach ($roles as $role) { $this->users->removeRole($user, $role); } foreach ($data['edit']['role'] as $role) { $this->users->assignRole($user, $role['id']); } return $this->jsonResponse(200, true, 'Successfully updated the user!', $this->users->getWithRoles($data['id'])); }
/** * @param RegisterUserCommand $command */ public function handle(RegisterUserCommand $command) { $user = UserFactory::register($command->username, $command->email, $command->password); $this->users->save($user); $this->dispatch($user->releaseEvents()); }
/** * Handle the data passed in via the user for registration. * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function postRegister() { $this->users->registerUser(Request::all()); return redirectTo('home'); }