b2in/database/seeders/CmsLegalSeeder.php
2026-04-10 17:18:17 +02:00

59 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Database\Seeders;
use FluxCms\Core\Models\CmsContent;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Lang;
class CmsLegalSeeder extends Seeder
{
/**
* Rechtstexte aus resources/lang/{locale}/b2in_legal.php → Gruppe „legal“.
*
* @var list<string>
*/
private const PAGE_KEYS = [
'impressum',
'privacy',
'terms',
'cookie_policy',
];
public function run(): void
{
foreach (self::PAGE_KEYS as $order => $key) {
/** @var array<string, mixed> $de */
$de = Lang::get('b2in_legal.'.$key, [], 'de');
/** @var array<string, mixed> $en */
$en = Lang::get('b2in_legal.'.$key, [], 'en');
if (! is_array($de) || $de === []) {
$this->command?->warn("CmsLegal: b2in_legal.{$key} (de) fehlt übersprungen.");
continue;
}
if (! is_array($en)) {
$en = $de;
}
CmsContent::query()->updateOrCreate(
[
'group' => 'legal',
'key' => $key,
],
[
'type' => 'json',
'value' => [
'de' => $de,
'en' => $en,
],
'order' => $order,
],
);
}
$this->command?->info('CmsLegal: '.count(self::PAGE_KEYS).' Seiten gespeichert (Gruppe legal).');
}
}