10-04-2026

This commit is contained in:
Kevin Adametz 2026-04-10 17:18:17 +02:00
parent 4d6b4930b2
commit 4bb89aad8c
836 changed files with 52961 additions and 5950 deletions

View file

@ -0,0 +1,90 @@
<?php
namespace Database\Seeders;
use FluxCms\Core\Models\CmsContent;
use FluxCms\Core\Services\CmsContentService;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Lang;
class NetzwerkPageCmsSeeder extends Seeder
{
/**
* Füllt nur fehlende Netzwerk-Seitenblöcke (CABINET-Premiumpartner, Immobilien-Hinweis) aus den Lang-Dateien.
* Bestehende CMS-Einträge werden nicht überschrieben.
*
* @var array<string, array{0: string, 1: string}>
*/
protected array $sections = [
'netzwerk_cabinet_partner' => ['netzwerk', 'cabinet_partner'],
'netzwerk_immobilien_hint' => ['netzwerk', 'immobilien_hint'],
];
public function run(): void
{
/** @var array<string, mixed> $langDe */
$langDe = Lang::get('b2in.themes.b2in', [], 'de');
/** @var array<string, mixed> $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';
}
}