<?php
 use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { public function up(): void { Schema::create('model_has_roles', function (Blueprint $t) { $t->unsignedBigInteger('role_id'); $t->string('model_type', 255); $t->unsignedBigInteger('model_id'); $t->index(['model_id', 'model_type'], 'model_has_roles_model_id_model_type_index'); $t->primary(['role_id', 'model_id', 'model_type']); $t->foreign('role_id', 'model_has_roles_role_id_foreign')->references('id')->on('roles')->onDelete('cascade'); }); } public function down(): void { Schema::dropIfExists('model_has_roles'); } }; 