1 回答

TA貢獻1836條經(jīng)驗 獲得超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 關注
- 162 瀏覽
添加回答
舉報