id(); $table->morphs('entity'); // Who has the access (User, Role, Permission) $table->morphs('accessible'); // What they have access to (Lection, Scenario, etc.) $table->json('context')->nullable(); $table->timestamp('expires_at')->nullable(); $table->timestamps(); // Prevent duplicate access entries $table->unique(['entity_type', 'entity_id', 'accessible_type', 'accessible_id'], 'access_unique'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists(config('roles.table_names.accesses', 'accesses')); } };