I understand that camel case is the usual convention, as per http://forums.laravel.io/viewtopic.php?id=8857
However, Laravel is using created_at and updated_at for timestamp fields.
I'm confused as what would be the best naming convention for field-names in the database? If camel cased, can I then switch created_at to createdAt, or should I use camel case for own fields and snake case for the timestamps?
It doesn't seem clear to me. Maybe Laravel wants me to use snake case all the way, like first_name in the database and $first_name in the PHP code, rather than firstName in the database, and $firstName in the code?
I hope someone can clarify...
Snake case is the convention for database fields and model attributes.
You can see it in the getter and setter (http://laravel.com/docs/eloquent#accessors-and-mutators) or relationships sections (http://laravel.com/docs/eloquent#relationships) in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With