yalcin Doğru olan:
Schema::create('role_user', function(Blueprint $table) {
$table->foreignId('role_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->unique(['role_id', 'user_id']);
});
Eğer bu tabloya bir model aracılığıyla da erişecekseniz:
Schema::create('role_user', function(Blueprint $table) {
$table->id();
$table->foreignId('role_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->unique(['role_id', 'user_id']);
$table->timestamps();
});