Coder Social home page Coder Social logo

Comments (8)

mnfgul avatar mnfgul commented on July 25, 2024 1

I found my answer. The reason was that getDirty() does not return changes in case of mass updates.

  • Model::update([]) does not work
  • $model->attribute = 'value'; $model->save(); works.

from revisionable.

Antonimo avatar Antonimo commented on July 25, 2024

looks like you still trying to do it manually together with the dirty method.
even the core only uses dirty:

$this->setKeysForSaveQuery($query)->update($dirty);

https://github.com/laravel/framework/blob/2680f371eed4b0d6d26818aee0e1eaff79892b96/src/Illuminate/Database/Eloquent/Model.php#L1345

from revisionable.

duellsy avatar duellsy commented on July 25, 2024

Not sure where you're referring to?

The changedRevisionableFields() method uses the getDirty() method, and checks that the updated item is indeed something that the owner wants tracked.

https://github.com/VentureCraft/revisionable/blob/master/src/Venturecraft/Revisionable/Revisionable.php#L164

from revisionable.

Antonimo avatar Antonimo commented on July 25, 2024

i'm referring bough to beforesave and changedRevisionableFields()
where you use $this->originalData and $this->updatedData.
I think in beforesave maybe you can do only

$this->dirty = $this->getDirty();

from revisionable.

duellsy avatar duellsy commented on July 25, 2024

Sure, essentially I wanted to clean the data my way before calling getDirty(), but it could just as easily only use the getDirty() method and do a cleanup on the results of that to create the $this->dirty value. Without wanting to be arrogant, I'm taking an 'if it aint broke, don't fix it' approach to this one.

If you want to make a pull request though, go for it and I'll merge it in.

from revisionable.

Antonimo avatar Antonimo commented on July 25, 2024

i'm taking the same approach for now =) maybe later if I have time Ill make
a pull request

2014-02-24 23:37 GMT+02:00 Chris Duell [email protected]:

Sure, essentially I wanted to clean the data my way before calling
getDirty(), but it could just as easily only use the getDirty() method
and do a cleanup on the results of that to create the $this->dirty value.
Without wanting to be arrogant, I'm taking an 'if it aint broke, don't fix
it' approach to this one.

If you want to make a pull request though, go for it and I'll merge it in.

Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-35942182
.

from revisionable.

duellsy avatar duellsy commented on July 25, 2024

Cool. There's also just recently been quite a few updates to the whole section for #36

from revisionable.

mnfgul avatar mnfgul commented on July 25, 2024

@duellsy Hi,

While making update, getDirty returns empty in my case. Details are as follow;

  • I am using trait in my model
  • Updating the model using;
    MyModel::whereId(1)->first()->update(['field' => 'value']).
  • This was not creating revisions. I digged into code and found that get $this->dirtyData = $this->getDirty(); return empty array.

Can you help about this issue.

Thanks.

from revisionable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.