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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners