*/ private const ARTICLE_ID_TO_SLUG = [ 1 => 'escrow-system-dubai-investoren', 2 => 'spotlight-al-jaddaf-hotspot', 3 => 'turnkey-investments-moeblierung-rendite', 4 => 'supply-chain-management-vertragssicherheit', 5 => 'local-for-local-regionaler-moebelhandel', ]; public function run(): void { foreach ($this->getArticles() as $i => $data) { CmsArticle::query()->updateOrCreate( ['slug' => $data['slug']], array_merge($data, ['order' => $i + 1]), ); } } /** * @return array> */ private function getArticles(): array { /** @var array> $articlesDe */ $articlesDe = Lang::get('b2in.articles', [], 'de'); /** @var array> $articlesEn */ $articlesEn = Lang::get('b2in.articles', [], 'en'); if (! is_array($articlesDe) || $articlesDe === []) { return []; } if (! is_array($articlesEn)) { $articlesEn = []; } ksort($articlesDe); $out = []; foreach ($articlesDe as $id => $rowDe) { $id = (int) $id; $slug = self::ARTICLE_ID_TO_SLUG[$id] ?? null; if ($slug === null) { continue; } $rowEn = $articlesEn[$id] ?? $rowDe; $out[] = [ 'slug' => $slug, 'title' => [ 'de' => (string) ($rowDe['title'] ?? ''), 'en' => (string) ($rowEn['title'] ?? ''), ], 'subtitle' => [ 'de' => (string) ($rowDe['subtitle'] ?? ''), 'en' => (string) ($rowEn['subtitle'] ?? ''), ], 'image' => (string) ($rowDe['image'] ?? ''), 'category' => (string) ($rowDe['category'] ?? ''), 'date_label' => (string) ($rowDe['date'] ?? ''), 'read_time' => (string) ($rowDe['readTime'] ?? ''), 'author' => is_array($rowDe['author'] ?? null) ? $rowDe['author'] : [], 'content' => [ 'de' => is_array($rowDe['content'] ?? null) ? $rowDe['content'] : [], 'en' => is_array($rowEn['content'] ?? null) ? $rowEn['content'] : [], ], 'is_published' => true, ]; } return $out; } }