<?php

namespace Database\Seeders;

use FluxCms\Core\Models\CmsLinkedinPost;
use Illuminate\Database\Seeder;

class CmsLinkedinPostSeeder extends Seeder
{
    public function run(): void
    {
        $posts = $this->getFallbackPosts();

        foreach ($posts as $index => $post) {
            CmsLinkedinPost::updateOrCreate(
                ['linkedin_id' => $post['id'] ?? null],
                [
                    'title' => ['de' => $post['title'], 'en' => $post['title']],
                    'excerpt' => ['de' => $post['excerpt'], 'en' => $post['excerpt']],
                    'content' => ['de' => $post['content'], 'en' => $post['content']],
                    'author' => $post['author'] ?? 'inno-projekt',
                    'date' => $post['date'] ?? null,
                    'url' => $post['url'] ?? null,
                    'image' => $post['image'] ?? null,
                    'tags' => $post['tags'] ?? [],
                    'source' => 'manual',
                    'is_published' => true,
                    'order' => $index,
                ]
            );
        }
    }

    /**
     * @return array<int, array<string, mixed>>
     */
    protected function getFallbackPosts(): array
    {
        return [
            [
                'id' => '1',
                'title' => 'How to relieve your project management team and accelerate projects.',
                'excerpt' => 'Project managers in the FMCG sector often find themselves caught between two stools...',
                'content' => '<strong>How to relieve your project management team and accelerate projects.</strong><br><br>Project managers in the FMCG sector often find themselves caught between two stools: they are expected to meet the strategic expectations of management while at the same time solving operational problems on the front line.',
                'date' => '2026-01-13',
                'author' => 'inno-projekt',
                'tags' => ['Update', 'LinkedIn'],
                'url' => 'https://www.linkedin.com/posts/inno-projekt-gmbh_how-to-relieve-your-project-management-team-activity-7416741386902790144-dfJf',
                'image' => 'post-1.jpeg',
            ],
            [
                'id' => '2',
                'title' => '2026 will be a clearly defined stress test for many packaging concepts.',
                'excerpt' => 'From August 12, 2026, the new EU Packaging Regulation (PPWR) will be largely binding...',
                'content' => '<strong>2026 will be a clearly defined stress test for many packaging concepts, primarily due to one thing:</strong><br><br>From August 12, 2026, the new EU Packaging Regulation (PPWR) will be largely binding.',
                'date' => '2026-01-09',
                'author' => 'inno-projekt',
                'tags' => ['Update', 'LinkedIn'],
                'url' => 'https://www.linkedin.com/posts/inno-projekt-gmbh_2026-will-be-a-clearly-defined-stress-test-activity-7414929446262018049-2JjY',
                'image' => 'post-2.jpeg',
            ],
            [
                'id' => '3',
                'title' => 'For many, the new working year is beginning these days.',
                'excerpt' => 'For us, it is time to take on responsibility again...',
                'content' => '<strong>For many, the new working year is beginning these days.</strong><br><br>For us, it is time to take on responsibility again.',
                'date' => '2026-01-02',
                'author' => 'inno-projekt',
                'tags' => ['Update', 'LinkedIn'],
                'url' => 'https://www.linkedin.com/posts/inno-projekt-gmbh_for-many-the-new-working-year-is-beginning-activity-7414204668291059712-MfKU',
                'image' => 'post-3.jpeg',
            ],
        ];
    }
}
