> Bisherige Standardpunkte der Startseite je Sprache */ public const FORMER_HOME_STATS = [ 'de' => ['Premium-Marken', 'Maßgefertigte Lösungen', 'Persönliche Beratung'], 'en' => ['Premium brands', 'Bespoke solutions', 'Personal consulting'], ]; public function run(): void { $updated = array_filter([ $this->apply('home', 'hero', 'hero', fn (mixed $current, string $locale) => $current === (self::FORMER_HOME_STATS[$locale] ?? null)), $this->apply('marken', 'hero', 'marken_hero', fn (mixed $current) => ! filled($current)), ]); $this->command?->info($updated === [] ? 'Hero-Vertrauenspunkte: bereits aktuell, nichts geändert.' : 'Hero-Vertrauenspunkte gesetzt: '.implode(', ', $updated).'.'); } /** * @param callable(mixed, string): bool $shouldReplace */ private function apply(string $group, string $key, string $langSection, callable $shouldReplace): ?string { $row = CmsContent::query()->where('group', $group)->where('key', $key)->first(); if (! $row) { return null; } $value = $row->getTranslations('value'); $changed = false; foreach ($value as $locale => $content) { $stats = trans("b2in.themes.b2in.{$langSection}.stats", [], $locale); if (! is_array($content) || ! is_array($stats) || ! $shouldReplace($content['stats'] ?? null, $locale)) { continue; } $content['stats'] = $stats; $value[$locale] = $content; $changed = true; } if (! $changed) { return null; } $row->value = $value; $row->save(); app(CmsContentService::class)->clearCache($group); return "{$group}/{$key}"; } }