/**
  * Update the specified resource in storage.
  *
  * @param $id
  * @throws \Acme\Core\Exceptions\EntityNotFoundException
  * @internal param $user
  * @return Response
  */
 public function update($id)
 {
     $user = $this->userRepository->findById($id);
     // Validate the inputs
     $val = $this->userRepository->getAdminEditForm($id);
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     if (!$this->userRepository->update($id, $val->getInputData())) {
         return Redirect::back()->with('errors', $this->userRepository->errors())->withInput();
     }
     $roles = is_array(Input::get('roles')) ? Input::get('roles') : [];
     $user->saveRoles($roles);
     // If user activate status have changed;
     if ($user->active != Input::get('active')) {
         $this->authService->changeActivateStatus($user);
     }
     return Redirect::action('AdminUsersController@index')->with('success', 'Updated user');
 }