Let's get familiar with a few more terms about Eloquent which are Accessors and Mutators or combined, they are called Attributes from Laravel 9.
If you work with projects before Laravel 9, there may be different syntax in older tutorials or examples
In this quick tutorial for Filament I will show you how to show calculate the "age" value from the "birth_date" field, show the age in the table, and customize its color.
I confess - during five years of working with Laravel, I've been fascinated by its "magic" and how little code is needed to actually make things work. But recently, as my projects grew in size, that "magic" started to become a problem. One of the typical example is Eloquent Accessors, so in this article I will put an argument against using them, and what to do instead.
Pretty common situation - you have a date field in the MySQL database, which has a default format of YYYY-MM-DD, but the users need to see/edit dates in MM/DD/YYYY. How do you handle it properly in Laravel?
Presenting to you a new Laravel framework feature, released this week by Taylor Otwell himself. You won't need to define getFooAttribute() and setFooAttribute(), instead you define just one foo(). How does it work?
Eloquent has a convenient feature called Accessors - you can define your own custom fields on top of existing in the database table. But then there's an Eloquent property $appends - should we use it or not? And what's the difference?