This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
The Eloquent getDirty()
method does not handle the casted attributes right now
#349
Comments
I love how this keeps coming up because Graham has closed all the issues. To the point it needs a master issue. He closes some saying "Duplicate" pointing to one he has closed for no reason ffs. |
Standard. |
It looks like cast checking for |
I think this is now implemented? |
I'm not sure the current implementation has resolved this issue In a project I'm currently working on (Laravel 6.2) I've had to implement the following workaround in order for the casting to work in
// following method is in a trait implemented by a model
public function getRawDiff()
{
$changed = $this->getDirty();
dump($changed['my_field_name']); // dumps a string
foreach($changed as $key => $value) {
if ($this->hasCast($key)) {
$changed[$key] = $this->castAttribute($key, $value);
}
}
dump($changed['my_field_name']); // gives me the array
//...
} If I'm reading that PR's implementation correctly, the first dump should return an array? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
For more details:
The text was updated successfully, but these errors were encountered: