<?php
// database/factories/QuestionFactory.php

namespace Database\Factories;

use App\Models\Question;
use Illuminate\Database\Eloquent\Factories\Factory;

class QuestionFactory extends Factory
{
    protected $model = Question::class;

    public function definition()
    {
        return [
            'libelle' => $this->faker->sentence,
            'image' => 'default.png',
        ];
    }

    public function configure()
    {
        return $this->afterCreating(function (Question $question) {
            // Attachez des réponses générées à la question
            $question->answers()->createMany(Answer::factory(4)->make()->toArray());
        });
    }
}
