Laravel 4.2 updated_at Table Field Always Updating
Here's the fix to the issue if you find the "updated_at" field in your database table always being updated even though the values do not actually change.
The "issue" is found within the getDirty() function within Eloquent\Model. It's caused by the way it compares the current value with the value being inserted/updated. The comparison is type sensative which can cause problems for certain values. Here's a github issue explaining the reasoning behind this from Taylor Otwell.
The solution we decided on was to ensure the value types being inserted and updated match what was previously there by forcing integers or doubles. It will also require you to use 1 or 0 instead of true or false for boolean values.
$int = 235; // force it to be integer $int = (int) 235; $bool = true; // becomes $bool = 1;
comments powered by Disqus