*/ protected array $sections = [ 'netzwerk_cabinet_partner' => ['netzwerk', 'cabinet_partner'], 'netzwerk_immobilien_hint' => ['netzwerk', 'immobilien_hint'], ]; public function run(): void { /** @var array $langDe */ $langDe = Lang::get('b2in.themes.b2in', [], 'de'); /** @var array $langEn */ $langEn = Lang::get('b2in.themes.b2in', [], 'en'); if (! is_array($langDe)) { $this->command?->warn('NetzwerkPageCmsSeeder: b2in.themes.b2in (de) fehlt.'); return; } if (! is_array($langEn)) { $langEn = []; } $created = 0; foreach ($this->sections as $sectionKey => [$group, $key]) { if (CmsContent::query()->where('group', $group)->where('key', $key)->exists()) { $this->command?->info("CMS {$group}.{$key} existiert bereits – übersprungen."); continue; } $sectionDataDe = $langDe[$sectionKey] ?? null; if ($sectionDataDe === null) { $this->command?->warn("Lang-Block {$sectionKey} fehlt – übersprungen."); continue; } $sectionDataEn = $langEn[$sectionKey] ?? $sectionDataDe; CmsContent::query()->create([ 'group' => $group, 'key' => $key, 'type' => $this->detectType($sectionDataDe), 'value' => [ 'de' => $sectionDataDe, 'en' => $sectionDataEn, ], 'order' => 0, ]); $created++; $this->command?->info("CMS {$group}.{$key} angelegt."); } if ($created > 0) { app(CmsContentService::class)->clearCache(); } } private function detectType(mixed $data): string { if (is_array($data)) { return 'json'; } if (is_string($data) && preg_match('/<[^>]+>/', $data)) { return 'html'; } return 'text'; } }