/** * Update a user's information. * * @param int $userId * * @return \Illuminate\Http\JsonResponse */ public function update($userId) { if (!($user = $this->users->findByKey($userId))) { return $this->notFound(); } try { $this->users->updateAsAdmin($user, $this->input()); return $this->jsonResponse(['user' => $user]); } catch (ValidationException $e) { return $this->error($e->getMessageBag()); } }
/** * Update a user's information. * * @param int $userId * * @return \Illuminate\Http\RedirectResponse */ public function update($userId) { if (!($user = $this->users->findByKey($userId))) { return $this->notFound(); } $redirect = $this->redirect('edit', [$user->id]); try { $this->users->updateAsAdmin($user, $this->input()); return $redirect->with('success', Lang::get('c::user.update-success')); } catch (AccessDeniedException $e) { return $redirect->with('error', Lang::get('c::auth.access-denied')); } catch (ValidationException $e) { return $redirect->withErrors($e); } }