<?php

namespace Database\Seeders;

use App\Models\Post;
use App\Models\Category;
use Illuminate\Database\Seeder;

class PostSeeder extends Seeder
{
    public function run(): void
    {
        $categories = Category::all();
        
        $posts = [
            [
                'title' => 'Manchester United Signs New Star Player',
                'slug' => 'manchester-united-signs-new-star-player',
                'content' => 'Manchester United has officially signed a new star player in a record-breaking transfer deal. The player brings exceptional talent and experience to the team.',
                'excerpt' => 'Manchester United completes major transfer signing.',
                'tags' => 'manchester united, transfer, premier league',
                'meta_title' => 'Manchester United New Signing - Latest Transfer News',
                'meta_description' => 'Manchester United completes major transfer deal for new star player.',
                'published_at' => now(),
            ],
            [
                'title' => 'Lakers Dominate in Latest NBA Game',
                'slug' => 'lakers-dominate-latest-nba-game',
                'content' => 'The Los Angeles Lakers showed dominant performance in their latest NBA game, securing a crucial victory that boosts their playoff chances.',
                'excerpt' => 'Lakers secure important victory in latest NBA matchup.',
                'tags' => 'lakers, nba, basketball',
                'meta_title' => 'Lakers NBA Victory - Game Highlights',
                'meta_description' => 'Los Angeles Lakers dominate in latest NBA game with impressive team performance.',
                'published_at' => now(),
            ],
            [
                'title' => 'Nadal Returns to Tennis Court After Injury',
                'slug' => 'nadal-returns-tennis-court-after-injury',
                'content' => 'Rafael Nadal makes his much-anticipated return to professional tennis after recovering from injury, showing promising form in his comeback match.',
                'excerpt' => 'Rafael Nadal returns to professional tennis after injury recovery.',
                'tags' => 'nadal, tennis, comeback',
                'meta_title' => 'Nadal Tennis Comeback - Return After Injury',
                'meta_description' => 'Rafael Nadal returns to tennis court showing excellent form after injury recovery.',
                'published_at' => now(),
            ],
        ];

        foreach ($posts as $index => $postData) {
            $category = $categories->random();
            $postData['category_id'] = $category->id;
            Post::create($postData);
        }
    }
}