}> */ public const SECTIONS = [ 'marken' => ['group' => 'marken', 'key' => 'hero', 'lang' => 'marken_hero', 'path' => []], 'about' => ['group' => 'about', 'key' => 'hero', 'lang' => 'about_hero', 'path' => []], 'contact' => ['group' => 'contact', 'key' => 'contact_form', 'lang' => 'contact_form', 'path' => ['hero']], ]; /** @var list Frühere Vorschläge, die durch den Text der Lang-Datei ersetzt werden */ public const FORMER_EYEBROWS = ['Unsere Marken', 'Our brands']; /** @var array> Abschnitt → Präfixe, die aus der Überschrift fallen */ public const TITLE_PREFIXES = [ 'about' => [ 'Über B2in: ', 'About B2in: ', ], ]; public function run(): void { $updated = []; foreach (self::SECTIONS as $name => $section) { $row = CmsContent::query()->where('group', $section['group'])->where('key', $section['key'])->first(); if (! $row) { continue; } $value = $row->getTranslations('value'); $changed = false; foreach ($value as $locale => $content) { if (! is_array($content)) { continue; } $langPath = implode('.', ['b2in.themes.b2in', $section['lang'], ...$section['path'], 'eyebrow']); $eyebrow = trans($langPath, [], $locale); $fieldPath = implode('.', [...$section['path'], 'eyebrow']); $current = data_get($content, $fieldPath); if ($eyebrow !== $langPath && $current !== $eyebrow && (! filled($current) || in_array($current, self::FORMER_EYEBROWS, true))) { data_set($content, $fieldPath, $eyebrow); $changed = true; } foreach (self::TITLE_PREFIXES[$name] ?? [] as $prefix) { $titlePath = implode('.', [...$section['path'], 'title']); $title = (string) data_get($content, $titlePath, ''); if (str_starts_with($title, $prefix)) { data_set($content, $titlePath, substr($title, strlen($prefix))); $changed = true; } } $value[$locale] = $content; } if ($changed) { $row->value = $value; $row->save(); app(CmsContentService::class)->clearCache($section['group']); $updated[] = $name; } } $this->command?->info($updated === [] ? 'Hero-Zeilen: bereits aktuell, nichts geändert.' : 'Hero-Zeilen ergänzt: '.implode(', ', $updated).'.'); } }