Laravel中的数据库/模型字段名称约定?

pre*_*eyz 6 php naming-conventions datamodel laravel

据我所知,骆驼案是通常的惯例,根据http://forums.laravel.io/viewtopic.php?id=8857

但是,Laravel使用created_at和updated_at作为时间戳字段.

我很困惑,因为数据库中字段名称的最佳命名约定是什么?如果使用camel,我可以将created_at切换到createdAt,还是应该将camel case用于自己的字段和蛇案例的时间戳?

这对我来说似乎并不清楚.也许Laravel希望我一直使用snake case,比如数据库中的first_name和PHP代码中的$ first_name,而不是数据库中的firstName,以及代码中的$ firstName?

我希望有人能澄清......

Ale*_*ski 13

Snake case是数据库字段和模型属性的约定.

您可以在文档中的getter和setter(http://laravel.com/docs/eloquent#accessors-and-mutators)或关系部分(http://laravel.com/docs/eloquent#relationships)中看到它.

  • 所以根据你的答案的正确方法将是代码:$ firstName = $ model-> first_name; (2认同)