主要实体Subject
有多个Comment
个,Comment
有多个Rate
个。
我应该如何命名迁移表?
我用Google搜索了hasMany关系的命名是subjects
和subject_comment
。
Rate
表应该命名为subject_comment_rate
还是subject_comments_rate
还是comment_rate
?
答案 0 :(得分:1)
默认情况下,laravel数据透视表遵循使用单数名称按字母顺序命名表格的方式,因此如果您想遵循约定,则应按照以下方式命名表格:
您可以偏离此约定,但在设置关系时必须指定数据透视表的名称