<?php

namespace Database\Factories;

use App\Enums\DifficultyLevelEnums;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Quiz>
 */
class QuizFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $is_free = fake()->boolean();

        return [
            'quiz_level' => fake()->randomElement(DifficultyLevelEnums::values()),
            'image' => '/assets/client/contest-image.png',
            'category_id' => 1,
            'has_level' => true,
            'point_to_pass' => $is_free ? 0 : 50,
            'banner_image' => '/assets/client/sample-video-thumbnail.png',
            'is_free' => $is_free,
        ];
    }

    /**
     * Configure the model factory.
     */
    public function configure(): static
    {
        return $this->afterCreating(function ($contest) {
            $contest->translations()->createMany([
                [
                    'locale' => 'en',
                    'title' => $this->faker->sentence(),
                    'description' => $this->faker->paragraph(),
                    'tags' => $this->faker->randomElements(['tag1', 'tag2', 'tag3', 'tag4', 'tag5'], 3),
                ],
                [
                    'locale' => 'bn',
                    'title' => $this->faker->sentence(),
                    'description' => $this->faker->paragraph(),
                    'tags' => $this->faker->randomElements(['tag1', 'tag2', 'tag3', 'tag4', 'tag5'], 3),
                ],
            ]);
        });
    }
}
