<?php

namespace Database\Factories;

use App\Models\Blog;
use App\Models\Category;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
 * @extends Factory<Blog>
 */
class BlogFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $title = fake()->sentence();

        return [
            'post' => $title,
            'slug' => Str::slug($title),
            'content' => fake()->paragraphs(3, true),
            'meta' => [
                'description' => fake()->sentence(),
                'keywords' => implode(',', fake()->words(5)),
            ],
            'custom_header' => fake()->optional()->sentence(),
            'post_image' => fake()->optional()->imageUrl(),
            'is_published' => fake()->boolean(80), // 80% chance of being published
            'category_id' => Category::factory(),
            'created_at' => now(),
            'updated_at' => now(),
        ];
    }
}
