-
Notifications
You must be signed in to change notification settings - Fork 11k
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
isDirty not working for json object #42788
Comments
This seems to be fixed by #41337 But that PR was only sent to 9.x. If maintainers consider this a bug fix, can you send a PR backporting it to 8.x? EDIT, as a workaround, casting to class BankAccount extends Model
{
protected $casts = ['bban' => 'json'];
} |
@rodrigopedra Thank you, I do want to create a PR to fix it for 8.x as well. |
@rodrigopedra PR created. #42793 |
RomainMazB
added a commit
to SunLabDev/wn-profile-plugin
that referenced
this issue
Jul 18, 2022
Make eloquent isDirty/isClean method work. See laravel/framework#42788 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description:
I'm trying to detect if an object is changed after the value of a property of a json field is updated. However, It's not detecting the change if the new value is a number with leading zeros. Note that the number is saved as a string so technically there shouldn't be any issues storing it along with all of its zeros.
Steps To Reproduce:
The aim is to update a property (
account_number
) ofbban
field (json object) on the$bankAccount
object.The code responsible for updating the values:
The result of dumping the json variable
bban
before and after the update:As can be seen, the value is updated however the
isDirty
method isn't able to detect the change, as a result,dd('values updated');
is never executed.It only fails when the new value has leading zeros. Also worth noting is that I am casting the
bban
field to json as it is the recommended approach.The text was updated successfully, but these errors were encountered: