Skip to main content

Search Results for "accessors"

We found 18 results for "accessors".

Tutorial 4 min read Free

The Biggest Problem with Eloquent Accessors "Magic"

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.

Tutorial 3 min read Free

Change date format with Accessors and Mutators

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?

Tutorial 2 min read Free

Why use $appends with Accessors in Eloquent?

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?