id(); $table->string('slug', 32); $table->json('title'); $table->json('body_markdown'); $table->string('locale_fallback', 5)->default('de'); $table->integer('version')->default(1); $table->timestamp('effective_from')->nullable(); $table->boolean('is_published')->default(false); $table->timestamps(); $table->unique(['slug', 'version']); }); } // Seed data if table exists (idempotent: updateOrInsert) if (Schema::hasTable('legal_pages')) { $now = now()->toDateString(); $rows = [ [ 'slug' => 'impressum', 'version' => 1, 'title' => json_encode(['de' => 'Impressum'], JSON_UNESCAPED_UNICODE), 'body_markdown' => json_encode(['de' => $this->impressumDe()], JSON_UNESCAPED_UNICODE), 'locale_fallback' => 'de', 'effective_from' => $now, 'is_published' => true, 'created_at' => now(), 'updated_at' => now(), ], [ 'slug' => 'datenschutz', 'version' => 1, 'title' => json_encode(['de' => 'Datenschutzerklärung'], JSON_UNESCAPED_UNICODE), 'body_markdown' => json_encode(['de' => $this->datenschutzDe($now)], JSON_UNESCAPED_UNICODE), 'locale_fallback' => 'de', 'effective_from' => $now, 'is_published' => true, 'created_at' => now(), 'updated_at' => now(), ], [ 'slug' => 'agb', 'version' => 1, 'title' => json_encode(['de' => 'Allgemeine Geschäftsbedingungen'], JSON_UNESCAPED_UNICODE), 'body_markdown' => json_encode(['de' => $this->agbDe($now)], JSON_UNESCAPED_UNICODE), 'locale_fallback' => 'de', 'effective_from' => $now, 'is_published' => true, 'created_at' => now(), 'updated_at' => now(), ], ]; foreach ($rows as $r) { DB::table('legal_pages')->updateOrInsert( ['slug' => $r['slug'], 'version' => $r['version']], $r ); } } } public function down(): void { if (app()->environment('local', 'testing')) { if (Schema::hasTable('legal_pages')) { DB::table('legal_pages')->whereIn('slug', ['impressum', 'datenschutz', 'agb'])->delete(); Schema::dropIfExists('legal_pages'); } } } private function impressumDe(): string { return <<