finishes 13 and 14

This commit is contained in:
2026-02-03 20:18:08 +01:00
parent c693cde038
commit baa43de4e1
47 changed files with 3522 additions and 21 deletions

View File

@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Question;
use App\Models\QuestionGroup;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* Factory for generating Question test data.
*
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Question>
*/
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',
]);
}
}