Alternatives to using Eloquent Accessor
Using computed columns in MySQL
Article illustrating how it is possible to use computed columns in our database tables to create additional model fields other than by using accessors.
Using Computed Columns in Laravel - Pine
Particularly useful where the model is exported via API or as an array and needs additional derived data.
Copy link