10-04-2026
This commit is contained in:
parent
4d6b4930b2
commit
4bb89aad8c
836 changed files with 52961 additions and 5950 deletions
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use FluxCms\Core\Models\CmsNewsItem;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CmsNewsItemSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private array $imageMapping = [
|
||||
'/assets/images/capability-overview_of_services.jpg' => 'capability-overview_of_services.webp',
|
||||
'/assets/images/capability-global-player.jpg' => 'capability-global-player.webp',
|
||||
'/assets/images/capability-national-champions.jpg' => 'capability-national-champions.webp',
|
||||
'/assets/images/story-taob.jpg?v1' => 'story-taob.webp',
|
||||
'/assets/images/story-taob.jpg' => 'story-taob.webp',
|
||||
'/assets/images/story-logo.jpg' => 'story-logo.webp',
|
||||
'/assets/images/leistung-4.jpg' => 'leistung-4.webp',
|
||||
'/assets/images/leistung-2.jpg' => 'leistung-2.webp',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private array $pdfMapping = [
|
||||
'pdfs/inno-projekt-Capability_9202_Leistungsuebersicht_de.pdf' => 'inno-projekt-Capability_9202_Leistungsuebersicht_de.pdf',
|
||||
'pdfs/inno-projekt-Capability_9101_GlobalPlayer_de.pdf' => 'inno-projekt-Capability_9101_GlobalPlayer_de.pdf',
|
||||
'pdfs/inno-projekt-Capability_9102_NationaleChampions_de.pdf' => 'inno-projekt-Capability_9102_NationaleChampions_de.pdf',
|
||||
];
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$locales = ['de', 'en'];
|
||||
$itemsByLocale = [];
|
||||
|
||||
foreach ($locales as $locale) {
|
||||
$path = lang_path("{$locale}/components.php");
|
||||
if (file_exists($path)) {
|
||||
$data = require $path;
|
||||
$itemsByLocale[$locale] = $data['news_band']['items'] ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
$deItems = $itemsByLocale['de'] ?? [];
|
||||
$enItems = $itemsByLocale['en'] ?? [];
|
||||
|
||||
$maxCount = max(count($deItems), count($enItems));
|
||||
|
||||
for ($i = 0; $i < $maxCount; $i++) {
|
||||
$de = $deItems[$i] ?? [];
|
||||
$en = $enItems[$i] ?? [];
|
||||
|
||||
$rawImage = $de['image'] ?? $en['image'] ?? null;
|
||||
$rawPdf = $de['pdf_path'] ?? $en['pdf_path'] ?? null;
|
||||
|
||||
CmsNewsItem::updateOrCreate(
|
||||
['order' => $i],
|
||||
[
|
||||
'icon' => $de['icon'] ?? $en['icon'] ?? null,
|
||||
'text' => array_filter(['de' => $de['text'] ?? null, 'en' => $en['text'] ?? null]),
|
||||
'title' => array_filter(['de' => $de['title'] ?? null, 'en' => $en['title'] ?? null]),
|
||||
'excerpt' => array_filter(['de' => $de['excerpt'] ?? null, 'en' => $en['excerpt'] ?? null]),
|
||||
'content' => array_filter(['de' => $de['content'] ?? null, 'en' => $en['content'] ?? null]),
|
||||
'image' => $this->resolveImage($rawImage),
|
||||
'date' => $de['date'] ?? $en['date'] ?? null,
|
||||
'author' => $de['author'] ?? $en['author'] ?? null,
|
||||
'link' => $de['link'] ?? $en['link'] ?? null,
|
||||
'pdf_path' => $this->resolvePdf($rawPdf),
|
||||
'pdf_open_text' => array_filter(['de' => $de['pdf_open_text'] ?? null, 'en' => $en['pdf_open_text'] ?? null]),
|
||||
'pdf_download_text' => array_filter(['de' => $de['pdf_download_text'] ?? null, 'en' => $en['pdf_download_text'] ?? null]),
|
||||
'is_published' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function resolveImage(?string $path): ?string
|
||||
{
|
||||
if (! $path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->imageMapping[$path] ?? pathinfo($path, PATHINFO_FILENAME).'.webp';
|
||||
}
|
||||
|
||||
private function resolvePdf(?string $path): ?string
|
||||
{
|
||||
if (! $path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->pdfMapping[$path] ?? basename($path);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue