public function postEditUser(Request $request)
 {
     $id = $request->get('id');
     DbHelper::startTransaction();
     try {
         $user = $this->f->process($request->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::route('users.edit', ["id" => $user->id])->withMessage(Config::get('acl_messages.flash.success.user_edit_success'));
 }
 /**
  * @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;
 }