Table Laravel Eloquent hasManyThrough 关系的命名约定
Table naming convention for Laravel Eloquent hasManyThrough relation
主要实体Subject
有多个Comment
,Comment
有多个Rate
。
我应该如何命名迁移 tables?
我用谷歌搜索了 hasMany 关系的命名是 subjects
和 subject_comment
。
Rate
table 应该命名为 subject_comment_rate
或 subject_comments_rate
或 comment_rate
吗?
默认情况下 laravel pivot tables 遵循按字母顺序使用单数名称命名 table 的惯例,因此如果您想遵循惯例,您应该命名您的 table就像这样:
- 科目
- 评论
- comment_subject
- 费率
- comment_rate
您可以偏离此约定,但您必须在设置关系时指定枢轴的名称table
主要实体Subject
有多个Comment
,Comment
有多个Rate
。
我应该如何命名迁移 tables?
我用谷歌搜索了 hasMany 关系的命名是 subjects
和 subject_comment
。
Rate
table 应该命名为 subject_comment_rate
或 subject_comments_rate
或 comment_rate
吗?
默认情况下 laravel pivot tables 遵循按字母顺序使用单数名称命名 table 的惯例,因此如果您想遵循惯例,您应该命名您的 table就像这样:
- 科目
- 评论
- comment_subject
- 费率
- comment_rate
您可以偏离此约定,但您必须在设置关系时指定枢轴的名称table