我在Laravel 5.1中有一种情况,我希望在现有关系中添加多对多关系。根据下图,我已经将所有项目都设置为绿色。
问题是,由于issue_person
表上没有主键,我不知道如何向用户添加多对多关系。有谁知道我会如何实现这个目标?
答案 0 :(得分:0)
因此,对此进行简单的回答似乎是编写一个迁移,将主键添加到原始issue_person
数据透视表,然后在issue_person
之间建立多对多关系和user
使用position_user
表。
我的迁移看起来像这样:
public function up()
{
Schema::table('issue_person', function (Blueprint $table) {
$table->increments('id');
});
}
public function down()
{
Schema::table('issue_person', function (Blueprint $table) {
$table->dropColumn('id');
});
}