1 回答
TA贡献1836条经验 获得超5个赞
使用多对多关系。在这种情况下,游戏模式可能有多个团队,反之亦然。
因此迁移将是这样的:
Schema::create('games', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('status');
$table->boolean('finished');
});
Schema::create('teams', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('abbreviation');
$table->string('country');
$table->timestamps();
});
Schema::create('game_team', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('game_id');
$table->integer('team_id');
$table->unsignedInteger('score');
$table->timestamps();
});
- 1 回答
- 0 关注
- 126 浏览
添加回答
举报