Does it work if you use snake case?
protected $appends = [
'full_name',
];
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Laravel's latest release includes a new and improved way of defining accessors and mutators (as explained in this Larabit by Jeffrey). I much prefer this way of defining accessors and mutators, however they don't seem to work with serialization, unless I'm doing something wrong. I happen to use a getFullNameAttribute in my application as well, which I had defined as
public function getFullNameAttribute(): string
{
return trim("$this->first_name $this->last_name");
}
and provided to my Vue front end by adding it to the $appends array;
protected $appends = [
'fullName',
];
However, when replacing this accessor with the new syntax as such;
public function fullName(): Attribute
{
return Attribute::get(fn() => trim("$this->first_name $this->last_name"));
}
I get a Call to undefined method App\Models\Model::getFullNameAttribute() exception. I can't find anything in the original pull request and its discussion nor has the documentation been updated yet, so does anyone here happen to know if this new feature is usable with serialization?
Does it work if you use snake case?
protected $appends = [
'full_name',
];
Please or to participate in this conversation.