Category: Laravel, PHP

In this article, I will talk about how to have camelCase properties in Eloquent models. One of the issues in using models with Eloquent ORM is having the default behavior of all the attributes in snake_case.

And is this way, because, the attributes have the same names of the columns of the database.

Like this: This has the advantage of being a base class, and this way is more difficult to forget to extend it.

The downside is, that the base class usually is more difficult to forget to use, and this way we would have a more coherent behaviour in all the models.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners