Laravel 8 new flexible accessors and mutators
ยท 1 min read

Till recently we had to follow some specific conventions to create accessors and mutators in Laravel by using the pattern get
or set
+ attribute name in PascalCase + the word Atribute
like so get{AttributeName}Attribute
or set{AttributeName}Attribute
.
Let's see an example:
As of Laravel 8.77 we can use a more compact syntax:
At the moment we can use both ways to cast attributes and define accessors and mutators so the old syntax is not considered a deprecated one. Cheers!!
Did you like this one?
I hope you really did...
Newsletter
Get notified about latest posts and updates once a week!!
You liked it?