Support the ongoing development of →
Laravel Eloquent
Last updated by @liquid207 4 months ago.

Hello @liquid207

Is the code you provider your whole class or only a part?

You can do a dump in your mutator but I suspect you have another value for name then you think.

    public function getNameAttribute($value)
        return strtoupper($value);

And strtoupper will make everything uppercase, so the expected result will be:

    "id" => 1,
    "name" => "FOO",

Sidenote: the mutators are rewritten to a new way, see:

The old version is currently still working so it shouldn't be a problem but If you need to change it I mostly suggest to update it :)



Thanks, you are right, I have updated description.

My key point is:

Incorrect accessor value ('' in this example) in Model::toArray() when a Model contains an accessor (getNameAttribute in this example) with the same name as a column and accessor name is added to Model::$appends


Sign in to participate in this thread!


Your banner here too?

Crosshadow liquid207 Joined 13 Mar 2024


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.