first commit
This commit is contained in:
29
database/factories/DepartmentFactory.php
Normal file
29
database/factories/DepartmentFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Department;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Department>
|
||||
*/
|
||||
class DepartmentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->words(2, true);
|
||||
|
||||
return [
|
||||
'code' => Str::slug(Str::ascii($name)),
|
||||
'name' => $name,
|
||||
'is_active' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
33
database/factories/HospitalUnitFactory.php
Normal file
33
database/factories/HospitalUnitFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\HospitalUnit;
|
||||
use App\Models\Profile;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<HospitalUnit>
|
||||
*/
|
||||
class HospitalUnitFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->words(3, true);
|
||||
|
||||
return [
|
||||
'profile_id' => Profile::factory(),
|
||||
'name' => $name,
|
||||
'slug' => Str::slug(Str::ascii($name)),
|
||||
'is_reporting_unit' => false,
|
||||
'report_input_type' => null,
|
||||
'is_active' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
26
database/factories/MedicalReportFactory.php
Normal file
26
database/factories/MedicalReportFactory.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\MedicalReport;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<MedicalReport>
|
||||
*/
|
||||
class MedicalReportFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => sprintf('МЕД %s', fake()->unique()->numberBetween(2026, 2035)),
|
||||
'year' => 2026,
|
||||
'input_overrides' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
49
database/factories/MedicalReportFormTemplateFactory.php
Normal file
49
database/factories/MedicalReportFormTemplateFactory.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\HospitalUnit;
|
||||
use App\Models\MedicalReportFormTemplate;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<MedicalReportFormTemplate>
|
||||
*/
|
||||
class MedicalReportFormTemplateFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$hospitalUnit = HospitalUnit::factory();
|
||||
|
||||
return [
|
||||
'hospital_unit_id' => $hospitalUnit,
|
||||
'department_key' => fake()->unique()->slug(2),
|
||||
'name' => fake()->sentence(3),
|
||||
'description' => fake()->sentence(),
|
||||
'schema' => [
|
||||
'title' => 'Тестовый шаблон',
|
||||
'description' => 'Тестовое описание',
|
||||
'sections' => [
|
||||
[
|
||||
'key' => 'main',
|
||||
'title' => 'Основной блок',
|
||||
'economist_label' => 'Тестовый шаблон / Основной блок',
|
||||
'fields' => [
|
||||
['key' => 'department_id', 'label' => 'Отделение', 'type' => 'department-select'],
|
||||
['key' => 'value', 'label' => 'Значение', 'type' => 'number'],
|
||||
],
|
||||
'default_entries' => [
|
||||
['department_id' => '', 'value' => '0'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'is_active' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
25
database/factories/ProfileFactory.php
Normal file
25
database/factories/ProfileFactory.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Profile;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Profile>
|
||||
*/
|
||||
class ProfileFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->unique()->word(),
|
||||
'sort_order' => fake()->numberBetween(1, 10),
|
||||
];
|
||||
}
|
||||
}
|
||||
60
database/factories/UserFactory.php
Normal file
60
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
'two_factor_secret' => null,
|
||||
'two_factor_recovery_codes' => null,
|
||||
'two_factor_confirmed_at' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model has two-factor authentication configured.
|
||||
*/
|
||||
public function withTwoFactor(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'two_factor_secret' => encrypt('secret'),
|
||||
'two_factor_recovery_codes' => encrypt(json_encode(['recovery-code-1'])),
|
||||
'two_factor_confirmed_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user