模型和表名称约定Laravel [英] Model and table name conventions Laravel
本文介绍了模型和表名称约定Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想了解Laravel中的模型和表约定.
I want to know model and table conventions in Laravel.
我现在有表用户和user_address,我不想使用
I have table users and user_address now I do not want to use
受保护的$ table ="user_address"
protected $table = "user_address"
属性.请在模型或表格中建议我正确的约定.
property. Please suggest me the right convention in model or table.
推荐答案
如果模型的名称为UserAddress
,则表的名称应为复数形式.因此它将是user_addresses
.
If the name of the model is UserAddress
, the name of the table should be plural. So it will be user_addresses
.
在此处上了解更多有关Laravel命名约定的信息.
Read more about Laravel naming conventions here.
这篇关于模型和表名称约定Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文