连接表的命名约定,在多对多关系中,在 Laravel
Naming convention for join tables, in a many to many relationship, in Laravel
我有 3 个 table。
前两个 table 是组和帐户。
一个帐户可以属于多个组。
一个群可以有多个账号。
换句话说就是多对多关系
因此我需要第三个 table,这是一个连接 table
在 Laravel 中此连接 table 的推荐命名约定是什么(或者一般而言)。
有什么命名约定吗?
我本来打算叫它 "GroupsAccountAssignment"。
支点名称 table 应为 account_group
。
如 laravel docs
To define this relationship, three database tables are needed: users,
roles, and role_user. The role_user table is derived from the
alphabetical order of the related model names, and contains the
user_id and role_id columns.
不过,您始终可以像下面这样覆盖默认命名约定:
账户模型:
return $this->belongsToMany('App\Group', 'GroupsAccountAssignment', 'account_id', 'group_id');
我有 3 个 table。
前两个 table 是组和帐户。
一个帐户可以属于多个组。
一个群可以有多个账号。
换句话说就是多对多关系
因此我需要第三个 table,这是一个连接 table
在 Laravel 中此连接 table 的推荐命名约定是什么(或者一般而言)。
有什么命名约定吗?
我本来打算叫它 "GroupsAccountAssignment"。
支点名称 table 应为 account_group
。
如 laravel docs
To define this relationship, three database tables are needed: users, roles, and role_user. The role_user table is derived from the alphabetical order of the related model names, and contains the user_id and role_id columns.
不过,您始终可以像下面这样覆盖默认命名约定:
账户模型:
return $this->belongsToMany('App\Group', 'GroupsAccountAssignment', 'account_id', 'group_id');