質問

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top