id(); $table->timestamps(); $table->string('name')->unique(); }); Schema::create('models', function (Blueprint $table) { $table->id(); $table->timestamps(); $table->string('name')->nullable(); $table->bigInteger('make_id')->unsigned()->nullable(); $table->foreign('make_id')->references('id')->on('makes'); $table->unique(['name','make_id']); }); Schema::create('software', function (Blueprint $table) { $table->id(); $table->timestamps(); $table->string('name')->nullable(); $table->bigInteger('model_id')->unsigned()->nullable(); $table->foreign('model_id')->references('id')->on('models'); $table->unique(['name','model_id']); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('software'); Schema::dropIfExists('models'); Schema::dropIfExists('makes'); } };