Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

previous Version revert is creating new version data #42

Open
majus28 opened this issue Nov 1, 2018 · 3 comments
Open

previous Version revert is creating new version data #42

majus28 opened this issue Nov 1, 2018 · 3 comments

Comments

@majus28
Copy link

majus28 commented Nov 1, 2018

$model->previousVersion()->revert(); is creating new data in version table
How can i disabled it.

@denjaland
Copy link

Sounds logical to me. The current version will become the previous version when you revert.
So you have an object which has value "A"; you change and save "B"; when you revert to "A" again, it sounds very logical to me that you have the history in your versions table A -> B (-> A (current version))

@Peter-Krebs
Copy link

I currently don't have an environment to test this on myself.

disableVersioning() is mentioned in the docs.
Does $model->disableVersioning()->previousVersion()->revert() skip creating the new version?
I would expect that it does.

@alexanderlakhneko
Copy link

$prev = $model->previousVersion();
        if($prev){
            $prev->revert();
            $model->versions()->latest()->take(2)->get()->each(function ($version) {
                    $version->delete();
            });
            return \Redirect::back()->with('message', 'Succes');
        } else {
            return \Redirect::back()->with('error', 'Erorr');
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants