*/ final class QuestionFactory extends Factory { protected $model = Question::class; /** * Define the model's default state. */ public function definition(): array { return [ 'question_group_id' => QuestionGroup::factory(), 'text' => fake()->sentence(), 'has_yes' => true, 'has_no' => true, 'has_na' => true, 'details' => null, 'sort_order' => fake()->numberBetween(0, 10), 'is_scored' => true, ]; } /** * Indicate that the question is not scored. */ public function nonScored(): static { return $this->state(fn (array $attributes) => [ 'is_scored' => false, ]); } /** * Indicate that the question is text-only (no yes/no/na options). */ public function textOnly(): static { return $this->state(fn (array $attributes) => [ 'has_yes' => false, 'has_no' => false, 'has_na' => false, 'is_scored' => false, 'details' => 'required', ]); } }