public function changeAvatar() { $user_id = Input::get('user_id'); $profile_id = Input::get('user_profile_id'); // validate input $validator = new UserProfileAvatarValidator(); if (!$validator->validate(Input::all())) { return Redirect::action('Jacopo\\Authentication\\Controllers\\UserController@editProfile', ['user_id' => $user_id])->withInput()->withErrors($validator->getErrors()); } // change picture try { $this->profile_repository->updateAvatar($profile_id); } catch (NotFoundException $e) { return Redirect::action('Jacopo\\Authentication\\Controllers\\UserController@editProfile', ['user_id' => $user_id])->withInput()->withErrors(new MessageBag(['avatar' => Config::get('laravel-authentication-acl::messages.flash.error.')])); } return Redirect::action('Jacopo\\Authentication\\Controllers\\UserController@editProfile', ['user_id' => $user_id])->withMessage(Config::get('laravel-authentication-acl::messages.flash.success.avatar_edit_success')); }
public function changeAvatar() { $user_id = Input::get('user_id'); $profile_id = Input::get('user_profile_id'); // validate input $validator = new UserProfileAvatarValidator(); if (!$validator->validate(Input::all())) { return Redirect::action('Jacopo\\Authentication\\Controllers\\UserController@editProfile', ['user_id' => $user_id])->withInput()->withErrors($validator->getErrors()); } // change picture try { $this->profile_repository->updateAvatar($profile_id); } catch (NotFoundException $e) { return Redirect::action('Jacopo\\Authentication\\Controllers\\UserController@editProfile', ['user_id' => $user_id])->withInput()->withErrors(new MessageBag(['avatar' => 'Cannot upload the file.'])); } return Redirect::action('Jacopo\\Authentication\\Controllers\\UserController@editProfile', ['user_id' => $user_id])->withMessage('Avatar changed succesfully'); }