finishes 13 and 14
This commit is contained in:
33
database/factories/AnswerFactory.php
Normal file
33
database/factories/AnswerFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Answer;
|
||||
use App\Models\Question;
|
||||
use App\Models\Session;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Answer test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Answer>
|
||||
*/
|
||||
final class AnswerFactory extends Factory
|
||||
{
|
||||
protected $model = Answer::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'session_id' => Session::factory(),
|
||||
'question_id' => Question::factory(),
|
||||
'value' => fake()->randomElement(['yes', 'no', 'not_applicable']),
|
||||
'text_value' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
29
database/factories/CategoryFactory.php
Normal file
29
database/factories/CategoryFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Category test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Category>
|
||||
*/
|
||||
final class CategoryFactory extends Factory
|
||||
{
|
||||
protected $model = Category::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->unique()->words(2, true),
|
||||
'sort_order' => fake()->numberBetween(0, 10),
|
||||
];
|
||||
}
|
||||
}
|
||||
38
database/factories/LogFactory.php
Normal file
38
database/factories/LogFactory.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Log;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Log test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Log>
|
||||
*/
|
||||
final class LogFactory extends Factory
|
||||
{
|
||||
protected $model = Log::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'action' => fake()->randomElement([
|
||||
'login',
|
||||
'logout',
|
||||
'session_started',
|
||||
'session_completed',
|
||||
'screening_started',
|
||||
'screening_completed',
|
||||
]),
|
||||
'metadata' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
60
database/factories/QuestionFactory.php
Normal file
60
database/factories/QuestionFactory.php
Normal 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',
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
database/factories/QuestionGroupFactory.php
Normal file
31
database/factories/QuestionGroupFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\QuestionGroup;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating QuestionGroup test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\QuestionGroup>
|
||||
*/
|
||||
final class QuestionGroupFactory extends Factory
|
||||
{
|
||||
protected $model = QuestionGroup::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'category_id' => Category::factory(),
|
||||
'name' => fake()->words(3, true),
|
||||
'sort_order' => fake()->numberBetween(0, 10),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
database/factories/ScreeningAnswerFactory.php
Normal file
31
database/factories/ScreeningAnswerFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Screening;
|
||||
use App\Models\ScreeningAnswer;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating ScreeningAnswer test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ScreeningAnswer>
|
||||
*/
|
||||
final class ScreeningAnswerFactory extends Factory
|
||||
{
|
||||
protected $model = ScreeningAnswer::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'screening_id' => Screening::factory(),
|
||||
'question_number' => fake()->numberBetween(1, 10),
|
||||
'value' => fake()->randomElement(['yes', 'no']),
|
||||
];
|
||||
}
|
||||
}
|
||||
53
database/factories/ScreeningFactory.php
Normal file
53
database/factories/ScreeningFactory.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Screening;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Screening test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Screening>
|
||||
*/
|
||||
final class ScreeningFactory extends Factory
|
||||
{
|
||||
protected $model = Screening::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'score' => null,
|
||||
'passed' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the screening passed.
|
||||
*/
|
||||
public function passed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'score' => 10,
|
||||
'passed' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the screening failed.
|
||||
*/
|
||||
public function failed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'score' => 3,
|
||||
'passed' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
51
database/factories/SessionFactory.php
Normal file
51
database/factories/SessionFactory.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Session;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Session test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Session>
|
||||
*/
|
||||
final class SessionFactory extends Factory
|
||||
{
|
||||
protected $model = Session::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'category_id' => Category::factory(),
|
||||
'screening_id' => null,
|
||||
'status' => 'in_progress',
|
||||
'score' => null,
|
||||
'result' => null,
|
||||
'basic_info' => null,
|
||||
'additional_comments' => null,
|
||||
'completed_at' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the session is completed.
|
||||
*/
|
||||
public function completed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => 'completed',
|
||||
'score' => 8,
|
||||
'result' => 'consult_leadership',
|
||||
'completed_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user