*/ protected array $skipSections = [ 'netzwerk_cabinet_partner', 'netzwerk_immobilien_hint', ]; public function run(): void { /** @var array $sectionMap */ $sectionMap = config('cms_section_map.sections', []); /** @var array $langKeys */ $langKeys = config('cms_section_map.lang_keys', []); /** @var array $configTheme */ $configTheme = config('content.themes.b2in', []); /** @var array $langDe */ $langDe = Lang::get('b2in.themes.b2in', [], 'de'); /** @var array $langEn */ $langEn = Lang::get('b2in.themes.b2in', [], 'en'); if (! is_array($langDe) || empty($langDe)) { $this->command?->warn('No b2in theme found in resources/lang/de/b2in.php (key: b2in.themes.b2in) – skipping.'); return; } if (! is_array($langEn)) { $langEn = []; } /** @var array $themeDe */ $themeDe = array_merge($configTheme, $langDe); /** @var array $themeEn */ $themeEn = array_merge($configTheme, $langEn); $created = 0; $updated = 0; foreach ($sectionMap as $sectionKey => $groupKeyPair) { if (in_array($sectionKey, $this->skipSections, true)) { continue; } $langSectionKey = $langKeys[$sectionKey] ?? $sectionKey; if (! array_key_exists($langSectionKey, $themeDe)) { $this->command?->warn("Unmapped or missing theme data for section: {$sectionKey} (lang key: {$langSectionKey}) – skipping."); continue; } $sectionDataDe = $themeDe[$langSectionKey]; $sectionDataEn = $themeEn[$langSectionKey] ?? $sectionDataDe; [$group, $key] = $groupKeyPair; $type = $this->detectType($sectionDataDe); $content = CmsContent::query() ->where('group', $group) ->where('key', $key) ->first(); $value = [ 'de' => $sectionDataDe, 'en' => $sectionDataEn, ]; if ($content) { $content->update([ 'type' => $type, 'value' => $value, ]); $updated++; } else { CmsContent::query()->create([ 'group' => $group, 'key' => $key, 'type' => $type, 'value' => $value, 'order' => 0, ]); $created++; } } $this->command?->info("CmsContent: {$created} created, {$updated} updated."); } private function detectType(mixed $data): string { if (is_array($data)) { return 'json'; } if (is_string($data) && preg_match('/<[^>]+>/', $data)) { return 'html'; } return 'text'; } }