*/ private const PLACEHOLDERS = ['+49 151 00000000', '+49 521 98610020']; /** @var array */ private const LOCALES = ['de', 'en']; public function run(): void { $row = CmsContent::query()->where('group', 'global')->where('key', 'contact')->first(); if (! $row) { CmsContent::create([ 'group' => 'global', 'key' => 'contact', 'type' => 'json', 'value' => array_fill_keys(self::LOCALES, ['whatsapp' => self::NUMBER]), 'order' => 0, ]); app(CmsContentService::class)->clearCache('global'); $this->command?->info('WhatsApp-Nummer: Eintrag global.contact angelegt.'); return; } $value = $row->getTranslations('value'); $changed = 0; foreach (self::LOCALES as $locale) { $section = is_array($value[$locale] ?? null) ? $value[$locale] : []; $current = trim((string) ($section['whatsapp'] ?? '')); if ($current !== '' && ! in_array($current, self::PLACEHOLDERS, true)) { continue; } $section['whatsapp'] = self::NUMBER; $value[$locale] = $section; $changed++; } if ($changed === 0) { $this->command?->info('WhatsApp-Nummer: bereits gepflegt, nichts geändert.'); return; } $row->value = $value; $row->save(); app(CmsContentService::class)->clearCache('global'); $this->command?->info("WhatsApp-Nummer gesetzt ({$changed} Sprache(n))."); } }