/**
  * @param array $input
  * @return mixed $user
  */
 protected function saveDbData(array $input)
 {
     DbHelper::startTransaction();
     try {
         $user = $this->user_repository->create($input);
         $this->profile_repository->create($this->createProfileInput($input, $user));
     } catch (UserExistsException $e) {
         DbHelper::rollback();
         $this->errors = new MessageBag(["model" => "User already exists."]);
         throw new UserExistsException();
     }
     DbHelper::commit();
     return $user;
 }
 public function postEditUser()
 {
     $id = Input::get('id');
     DbHelper::startTransaction();
     try {
         $user = $this->f->process(Input::all());
         $this->profile_repository->attachEmptyProfile($user);
     } catch (JacopoExceptionsInterface $e) {
         DbHelper::rollback();
         $errors = $this->f->getErrors();
         // passing the id incase fails editing an already existing item
         return Redirect::route("users.edit", $id ? ["id" => $id] : [])->withInput()->withErrors($errors);
     }
     DbHelper::commit();
     return Redirect::action('Jacopo\\Authentication\\Controllers\\UserController@editUser', ["id" => $user->id])->withMessage(Config::get('laravel-authentication-acl::messages.flash.success.user_edit_success'));
 }