public function update($userId)
 {
     //Verify the user can access this user record - we don't need the record just the auth check
     $user = User::findWithPermission($userId);
     $input = \Input::all();
     //Clear the profile photo field as this is handled separately below.
     unset($input['new_profile_photo']);
     if (empty($input['profile_photo_private'])) {
         $input['profile_photo_private'] = false;
     }
     //Trim all the data so some of the validation doesn't choke on spaces
     foreach ($input as $key => $value) {
         if (is_string($value)) {
             $input[$key] = trim($value);
         }
     }
     $this->profileValidator->validate($input, $userId);
     $this->profileRepo->update($userId, $input);
     if (\Input::file('new_profile_photo')) {
         try {
             $this->userImage->uploadPhoto($user->hash, \Input::file('new_profile_photo')->getRealPath(), true);
             $this->profileRepo->update($userId, ['new_profile_photo' => 1]);
             \Notification::success("Photo uploaded, it will be checked and appear shortly");
         } catch (\Exception $e) {
             \Log::error($e);
         }
     } else {
         \Notification::success("Profile Updated");
     }
     return \Redirect::route('members.show', $userId);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Illuminate\Http\RedirectResponse
  */
 public function store()
 {
     $input = \Input::only('given_name', 'family_name', 'email', 'secondary_email', 'password', 'phone', 'address.line_1', 'address.line_2', 'address.line_3', 'address.line_4', 'address.postcode', 'monthly_subscription', 'emergency_contact', 'new_profile_photo', 'profile_photo_private', 'rules_agreed');
     $this->userForm->validate($input);
     $this->profileValidator->validate($input);
     $user = $this->userRepository->registerMember($input, !\Auth::guest() && \Auth::user()->hasRole('admin'));
     if (\Input::file('new_profile_photo')) {
         try {
             $this->userImage->uploadPhoto($user->hash, \Input::file('new_profile_photo')->getRealPath(), true);
             $this->profileRepo->update($user->id, ['new_profile_photo' => 1, 'profile_photo_private' => $input['profile_photo_private']]);
         } catch (\Exception $e) {
             \Log::error($e);
         }
     }
     //If this isn't an admin user creating the record log them in
     if (\Auth::guest() || !\Auth::user()->isAdmin()) {
         \Auth::login($user);
     }
     return \Redirect::route('account.show', [$user->id]);
 }