Comments (7)
Hmmm interesting, if there's any issues in determining which fields have been updated and which are unchanged, it points to a possible bug in Eloquents
getDirty()
function: https://github.com/laravel/framework/blob/master/src/Illuminate/Database/Eloquent/Model.php#L2162
In particular, the following line is equating to true:
if ( ! array_key_exists($key, $this->original) or $value != $this->original[$key])
Since the key
would exist in the original
array, it seems as though $value != $this->original[$key]
is true...
As a test, perhaps do a var_dump
of the object as it currently exists, and then also directly before saving it, and compare the value on initial load and then before saving
from revisionable.
Yep...that is the problem. http://paste.laravel.com/wEV
Looks like it's being cast to an integer where when it's in the database it is a string. I just confirmed that the disabled field is a boolean in the migration $table->boolean('disabled')->default(0);
...
Not sure if you typo'd it or not, but in my version of Laravel that line is:
if ( ! array_key_exists($key, $this->original) or $value !== $this->original[$key])
(notice the double equal...). Just to be certain, I changed mine to a single equal and it still has the same problem. Hmmm...time to file a bug on the Laravel repo? Do you experience the same issue on boolean fields?
from revisionable.
I copied that line from the Laravel project in it's latest form on github.
Might be worth opening an issue in Laravel to confirm that it is correct behaviour... if they feel that booleans should continue to be cast to an int when pulled from the database, then we'll have to adhere to that and make a fix to cater for it.
from revisionable.
Oh actually... my apologies, the latest Laravel has !==
, I was looking at an older version. This more explicit comparison wouldn't be helping, since in theory
true != 0
would return a fail
Seems it was updated in Laravel about a month back laravel/framework@e247073
from revisionable.
Found the fix here after asking in IRC. :P
laravel/framework#1429 (comment)
from revisionable.
Awesome, nice find. If enough other people have this issue, then we'll look at putting this in revisionable core
from revisionable.
I can't seem to get this to work, unfortunately. Even when I have the getAttribute in my base model, it never gets called on my boolean fields if they are changing. Any ideas? I think I'm in need of tutoring... 😄
from revisionable.
Related Issues (20)
- Disable system wide on specific projects HOT 1
- identifiableName() doesnt work with model User HOT 1
- additional fields not beeing stored when Storing Creations HOT 2
- Supporting multiple auth HOT 1
- Nothing happens when I try to save instance from `Comment` model HOT 2
- Explicitly providing `user_id` to Revisionable HOT 1
- Revisionable not creating revision entries for belongsToMany relationships HOT 1
- Revisionable is largely abandonware – look elsewhere HOT 3
- More documentation around identifiableName() HOT 2
- so i created this fuction to return 'meta', anyone knows how to access [key] => date_achat / i want to display only the arrays where key == date_achat
- DateTime object to json serialization
- The article link in Readme.md is not working
- use in tables without integer primary key
- New Feature: Save changed and append custom data HOT 3
- Laravel 10 Support
- Is it a part instead of the whole? HOT 1
- Consider storing only attributes that have been changed and only the diff values HOT 1
- Please allow table name to be configurable HOT 2
- Invalid foreign key for SoftDelete returns unknown instead of the original id HOT 1
- Display revisions in Laravel Nova HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from revisionable.