id(); $table->string('slug')->unique(); $table->string('label'); $table->timestamps(); }); Schema::create('editorial_dimension_values', function (Blueprint $table) { $table->id(); $table->foreignId('editorial_dimension_id')->constrained()->cascadeOnDelete(); $table->string('slug'); $table->string('label'); $table->timestamps(); $table->unique(['editorial_dimension_id', 'slug']); }); Schema::create('identity_dimension_values', function (Blueprint $table) { $table->id(); $table->string('subject_type'); $table->unsignedBigInteger('subject_id'); $table->foreignId('editorial_dimension_value_id')->constrained()->cascadeOnDelete(); $table->string('origin'); $table->timestamps(); $table->unique(['subject_type', 'subject_id', 'editorial_dimension_value_id'], 'identity_dimension_unique'); }); $now = now(); $dimensionId = DB::table('editorial_dimensions')->insertGetId([ 'slug' => 'saeule', 'label' => 'Fachliche Säule', 'created_at' => $now, 'updated_at' => $now, ]); foreach (DB::table('pillars')->orderBy('id')->get() as $pillar) { $slug = 'pfeiler-'.$pillar->id; $valueId = DB::table('editorial_dimension_values')->insertGetId([ 'editorial_dimension_id' => $dimensionId, 'slug' => $slug, 'label' => $pillar->name, 'created_at' => $now, 'updated_at' => $now, ]); foreach (DB::table('content_element_pillar')->where('pillar_id', $pillar->id)->get() as $link) { DB::table('identity_dimension_values')->insert([ 'subject_type' => 'App\\Domain\\Catalog\\ContentElement', 'subject_id' => $link->content_element_id, 'editorial_dimension_value_id' => $valueId, 'origin' => 'direkt', 'created_at' => $now, 'updated_at' => $now, ]); } } } public function down(): void { Schema::dropIfExists('identity_dimension_values'); Schema::dropIfExists('editorial_dimension_values'); Schema::dropIfExists('editorial_dimensions'); } };