feat(factories): add new factories and update existing ones for all models

This commit is contained in:
F4ilji
2026-09-18 01:39:25 +05:00
parent c7a779d9aa
commit 02455fbca7
31 changed files with 530 additions and 15 deletions
@@ -36,7 +36,7 @@ class SlideFactory extends Factory
'start_time' => $this->faker->dateTimeBetween('-1 week', '+1 week'),
'end_time' => $this->faker->dateTimeBetween('+1 week', '+2 weeks'),
'sort' => $this->faker->numberBetween(1, 10),
// slider_id будет установлен в сидере
'slider_id' => \App\Containers\Widget\Models\Slider::factory(),
'slidable_id' => null,
'slidable_type' => null,
];
@@ -0,0 +1,26 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class AcademicJournalFactory extends Factory
{
protected $model = \App\Containers\Science\Models\AcademicJournal::class;
public function definition(): array
{
$title = $this->faker->unique()->words(3, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'main_info' => ['description' => $this->faker->paragraph],
'chief_editor' => ['name' => $this->faker->name],
'editors' => [['name' => $this->faker->name], ['name' => $this->faker->name]],
'for_authors' => ['requirements' => $this->faker->paragraph],
'is_active' => $this->faker->boolean(80),
'search_data' => $this->faker->words(5, true),
];
}
}
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use App\Containers\AdditionalEducation\Models\DirectionAdditionalEducation;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class AdditionalEducationCategoryFactory extends Factory
{
protected $model = \App\Containers\AdditionalEducation\Models\AdditionalEducationCategory::class;
public function definition(): array
{
$title = $this->faker->unique()->words(2, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'is_active' => $this->faker->boolean(80),
'dir_addit_educat_id' => DirectionAdditionalEducation::factory(),
];
}
}
@@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use App\Containers\AdditionalEducation\Models\AdditionalEducationCategory;
use App\Ship\Enums\Education\FormEducation;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class AdditionalEducationFactory extends Factory
{
protected $model = \App\Containers\AdditionalEducation\Models\AdditionalEducation::class;
public function definition(): array
{
$title = $this->faker->unique()->words(4, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'content' => [['type' => 'paragraph', 'data' => ['content' => $this->faker->paragraph]]],
'category_id' => AdditionalEducationCategory::factory(),
'target_group' => $this->faker->randomElement(['Студенты', 'Педагоги', 'Специалисты', 'Все']),
'qualification' => $this->faker->optional()->word,
'price' => $this->faker->numberBetween(5000, 150000),
'learning_time' => $this->faker->randomElement([72, 144, 216, 360, 720]),
'form_education' => $this->faker->randomElement([FormEducation::FULL_TIME->value, FormEducation::FULL_PART_TIME->value, FormEducation::PART_TIME->value]),
'is_active' => $this->faker->boolean(80),
'search_data' => $this->faker->words(5, true),
];
}
}
@@ -0,0 +1,41 @@
<?php
namespace Database\Factories;
use App\Ship\Enums\Education\AdmissionCampaignStatus;
use App\Ship\Enums\Education\LevelEducational;
use Illuminate\Database\Eloquent\Factories\Factory;
class AdmissionCampaignFactory extends Factory
{
protected $model = \App\Containers\Education\Models\AdmissionCampaign::class;
public function definition(): array
{
$levels = [
LevelEducational::BACHELOR->value,
LevelEducational::MASTER->value,
LevelEducational::SPECIALIST->value,
];
$info = array_map(function ($lvl) {
$och = $this->faker->numberBetween(10, 100);
$zaoch = $this->faker->numberBetween(5, 50);
return [
'edu_name' => $lvl,
'total_programs' => $this->faker->numberBetween(3, 10),
'och_count' => $och,
'zaoch_count' => $zaoch,
'budget_places' => (int) ($och * 0.6),
'non_budget_places' => (int) ($och * 0.4) + $zaoch,
];
}, $levels);
return [
'name' => 'Прием ' . $this->faker->year . ' года',
'academic_year' => $this->faker->year . '-' . ($this->faker->year + 1),
'status' => AdmissionCampaignStatus::ACTIVE->value,
'info' => $info,
];
}
}
@@ -0,0 +1,22 @@
<?php
namespace Database\Factories;
use App\Containers\Education\Models\AdmissionCampaign;
use App\Containers\Education\Models\EducationalProgram;
use Illuminate\Database\Eloquent\Factories\Factory;
class AdmissionPlanFactory extends Factory
{
protected $model = \App\Containers\Education\Models\AdmissionPlan::class;
public function definition(): array
{
return [
'educational_programs_id' => EducationalProgram::factory(),
'admission_campaigns_id' => AdmissionCampaign::factory(),
'exams' => $this->faker->words(3, true),
'contests' => [['name' => $this->faker->word, 'places' => $this->faker->numberBetween(5, 50)]],
];
}
}
+2
View File
@@ -10,6 +10,8 @@ use Illuminate\Support\Str;
*/
class CategoryFactory extends Factory
{
protected $model = \App\Containers\Article\Models\Category::class;
/**
* Define the model's default state.
*
@@ -0,0 +1,26 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class ContactWidgetFactory extends Factory
{
protected $model = \App\Containers\Widget\Models\ContactWidget::class;
public function definition(): array
{
$title = $this->faker->unique()->words(2, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'content' => [
['type' => 'phone', 'value' => $this->faker->phoneNumber],
['type' => 'email', 'value' => $this->faker->safeEmail],
['type' => 'address', 'value' => $this->faker->address],
],
'is_active' => $this->faker->boolean(80),
];
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use App\Containers\Widget\Enums\CustomFormStatus;
use Illuminate\Database\Eloquent\Factories\Factory;
class CustomFormFactory extends Factory
{
protected $model = \App\Containers\Widget\Models\CustomForm::class;
public function definition(): array
{
return [
'title' => $this->faker->unique()->words(2, true),
'description' => $this->faker->sentence,
'form_id' => $this->faker->unique()->uuid,
'columns' => [
['name' => 'name', 'type' => 'text', 'required' => true],
['name' => 'email', 'type' => 'email', 'required' => true],
['name' => 'message', 'type' => 'textarea', 'required' => false],
],
'button' => 'Отправить',
'send_message' => 'Спасибо за обращение!',
'mail_settings' => ['to' => $this->faker->safeEmail],
'settings' => null,
'status' => $this->faker->randomElement([CustomFormStatus::PUBLISHED->value, CustomFormStatus::HIDDEN->value]),
];
}
}
@@ -0,0 +1,24 @@
<?php
namespace Database\Factories;
use App\Containers\Widget\Models\CustomForm;
use Illuminate\Database\Eloquent\Factories\Factory;
class CustomFormResponseFactory extends Factory
{
protected $model = \App\Containers\Widget\Models\CustomFormResponse::class;
public function definition(): array
{
return [
'custom_form_id' => CustomForm::factory(),
'answers' => [
'name' => $this->faker->name,
'email' => $this->faker->safeEmail,
'message' => $this->faker->paragraph,
],
'checked' => $this->faker->boolean(30),
];
}
}
+2
View File
@@ -11,6 +11,8 @@ use Illuminate\Support\Str;
*/
class DepartmentFactory extends Factory
{
protected $model = \App\Containers\InstituteStructure\Models\Department::class;
/**
* Define the model's default state.
*
@@ -0,0 +1,21 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class DirectionAdditionalEducationFactory extends Factory
{
protected $model = \App\Containers\AdditionalEducation\Models\DirectionAdditionalEducation::class;
public function definition(): array
{
$title = $this->faker->unique()->words(3, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'is_active' => $this->faker->boolean(80),
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use App\Ship\Enums\Education\LevelEducational;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class DirectionStudyFactory extends Factory
{
protected $model = \App\Containers\Education\Models\DirectionStudy::class;
public function definition(): array
{
$name = $this->faker->unique()->words(3, true);
return [
'uuid' => $this->faker->uuid,
'name' => $name,
'slug' => Str::slug($name),
'code' => $this->faker->numerify('##.##.##'),
'lvl_edu' => $this->faker->randomElement([
LevelEducational::BACHELOR->value,
LevelEducational::MASTER->value,
LevelEducational::SPECIALIST->value,
]),
'info' => ['description' => $this->faker->paragraph],
];
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class DivisionFactory extends Factory
{
protected $model = \App\Containers\InstituteStructure\Models\Division::class;
public function definition(): array
{
$title = $this->faker->unique()->words(3, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'description' => ['description' => $this->faker->paragraph],
'is_active' => $this->faker->boolean(80),
'search_data' => $this->faker->words(5, true),
];
}
}
@@ -6,11 +6,13 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class EducationalGroupFactory extends Factory
{
protected $model = \App\Containers\Schedule\Models\EducationalGroup::class;
public function definition(): array
{
return [
'title' => $this->faker->words(3, true),
'faculty_id' => \App\Models\Faculty::factory(),
'faculty_id' => \App\Containers\InstituteStructure\Models\Faculty::factory(),
'education_form_id' => $this->faker->numberBetween(1, 3),
'created_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
'updated_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
@@ -0,0 +1,36 @@
<?php
namespace Database\Factories;
use App\Containers\Education\Models\DirectionStudy;
use App\Ship\Enums\Education\LevelEducational;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class EducationalProgramFactory extends Factory
{
protected $model = \App\Containers\Education\Models\EducationalProgram::class;
public function definition(): array
{
$name = $this->faker->unique()->words(4, true);
return [
'uuid' => $this->faker->uuid,
'name' => $name,
'slug' => Str::slug($name),
'about_program' => ['description' => $this->faker->paragraph],
'program_features' => ['features' => $this->faker->paragraph],
'inner_code' => $this->faker->numerify('###'),
'lvl_edu' => $this->faker->randomElement([
LevelEducational::BACHELOR->value,
LevelEducational::MASTER->value,
LevelEducational::SPECIALIST->value,
]),
'status' => $this->faker->randomElement(['active', 'inactive']),
'lang_stud' => $this->faker->randomElement(['ru', 'en']),
'learning_forms' => ['full_time', 'part_time'],
'direction_study_id' => DirectionStudy::factory(),
'search_data' => $this->faker->words(5, true),
];
}
}
@@ -10,6 +10,8 @@ use Illuminate\Support\Str;
*/
class EventCategoryFactory extends Factory
{
protected $model = \App\Containers\Event\Models\EventCategory::class;
/**
* Define the model's default state.
*
+2
View File
@@ -11,6 +11,8 @@ use Illuminate\Support\Str;
*/
class EventFactory extends Factory
{
protected $model = \App\Containers\Event\Models\Event::class;
/**
* Define the model's default state.
*
+2
View File
@@ -10,6 +10,8 @@ use Illuminate\Support\Str;
*/
class FacultyFactory extends Factory
{
protected $model = \App\Containers\InstituteStructure\Models\Faculty::class;
/**
* Define the model's default state.
*
@@ -0,0 +1,19 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class IntegrationCredentialFactory extends Factory
{
protected $model = \App\Containers\Dashboard\Models\IntegrationCredential::class;
public function definition(): array
{
return [
'provider' => $this->faker->unique()->randomElement(['vk', 'telegram', 'email', '1c']),
'payload' => ['token' => $this->faker->uuid, 'secret' => $this->faker->sha256],
'is_active' => $this->faker->boolean(80),
];
}
}
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use App\Containers\Science\Models\AcademicJournal;
use Illuminate\Database\Eloquent\Factories\Factory;
class JournalIssueFactory extends Factory
{
protected $model = \App\Containers\Science\Models\JournalIssue::class;
public function definition(): array
{
return [
'title' => 'Выпуск ' . $this->faker->numberBetween(1, 12) . '/' . $this->faker->year,
'path_file' => 'journals/' . $this->faker->uuid . '.pdf',
'year_publication' => $this->faker->numberBetween(2020, 2025),
'is_active' => $this->faker->boolean(80),
'sort' => $this->faker->optional()->numberBetween(1, 100),
'academic_journal_id' => AcademicJournal::factory(),
];
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class MainSectionFactory extends Factory
{
protected $model = \App\Containers\AppStructure\Models\MainSection::class;
public function definition(): array
{
$title = $this->faker->unique()->words(2, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'sort' => $this->faker->numberBetween(1, 100),
];
}
}
+21 -9
View File
@@ -2,22 +2,34 @@
namespace Database\Factories;
use App\Containers\AppStructure\Models\SubSection;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Page>
*/
class PageFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
protected $model = \App\Containers\AppStructure\Models\Page::class;
public function definition(): array
{
$title = $this->faker->words(3, true);
$slug = Str::slug($title);
return [
//
'title' => $title,
'slug' => $slug,
'path' => $slug,
'content' => [['type' => 'paragraph', 'data' => ['content' => $this->faker->paragraph]]],
'is_registered' => false,
'is_visible' => true,
'searchable' => true,
'is_url' => false,
'code' => 200,
'sub_section_id' => null,
'search_data' => $this->faker->words(5, true),
'settings' => null,
'sort' => $this->faker->numberBetween(1, 100),
'icon' => null,
];
}
}
@@ -0,0 +1,25 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class PageReferenceListFactory extends Factory
{
protected $model = \App\Containers\Widget\Models\PageReferenceList::class;
public function definition(): array
{
$title = $this->faker->unique()->words(3, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'content' => [
['title' => $this->faker->words(2, true), 'url' => $this->faker->url],
['title' => $this->faker->words(2, true), 'url' => $this->faker->url],
],
'is_active' => $this->faker->boolean(80),
];
}
}
+2
View File
@@ -10,6 +10,8 @@ use Illuminate\Support\Str;
class PostFactory extends Factory
{
protected $model = \App\Containers\Article\Models\Post::class;
/**
* Define the model's default state.
*
+3 -1
View File
@@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class ScheduleFactory extends Factory
{
protected $model = \App\Containers\Schedule\Models\Schedule::class;
public function definition(): array
{
$fileName = $this->faker->unique()->word . '.pdf';
@@ -17,7 +19,7 @@ class ScheduleFactory extends Factory
'path' => 'schedules/' . $this->faker->slug . '-' . time() . '.pdf'
]
],
'educational_group_id' => \App\Models\EducationalGroup::factory(),
'educational_group_id' => \App\Containers\Schedule\Models\EducationalGroup::factory(),
'created_at' => $this->faker->dateTimeBetween('-6 months', 'now'),
'updated_at' => $this->faker->dateTimeBetween('-6 months', 'now'),
];
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class SliderFactory extends Factory
{
protected $model = \App\Containers\Widget\Models\Slider::class;
public function definition(): array
{
$title = $this->faker->unique()->words(2, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'is_active' => $this->faker->boolean(80),
];
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use App\Containers\AppStructure\Models\MainSection;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class SubSectionFactory extends Factory
{
protected $model = \App\Containers\AppStructure\Models\SubSection::class;
public function definition(): array
{
$title = $this->faker->unique()->words(2, true);
return [
'title' => $title,
'slug' => Str::slug($title),
'sort' => $this->faker->numberBetween(1, 100),
'main_section_id' => MainSection::factory(),
];
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class TagFactory extends Factory
{
protected $model = \App\Containers\Article\Models\Tag::class;
public function definition(): array
{
return [
'name' => ['ru' => $this->faker->unique()->word, 'en' => $this->faker->unique()->word],
'slug' => ['ru' => $this->faker->unique()->slug(1), 'en' => $this->faker->unique()->slug(1)],
'type' => $this->faker->optional()->randomElement(['post', 'event', 'page']),
'order_column' => $this->faker->optional()->numberBetween(1, 100),
];
}
}
+3 -2
View File
@@ -10,6 +10,8 @@ use Illuminate\Database\Eloquent\Factories\Factory;
*/
class UserDetailFactory extends Factory
{
protected $model = \App\Containers\User\Models\UserDetail::class;
/**
* Define the model's default state.
*
@@ -36,7 +38,7 @@ class UserDetailFactory extends Factory
};
return [
'user_id' => null, // Это будет установлено позже
'user_id' => User::factory(),
'is_only_worker' => $this->faker->boolean,
'photo' => "images/01J7TKMCR55KY7ARS2DA6VVAHE.jpg",
'academicTitle' => $this->faker->word,
@@ -48,7 +50,6 @@ class UserDetailFactory extends Factory
'professionalDevelopment' => $generateItems(),
'workExperience' => $this->faker->randomDigit(),
'attendedConferences' => $generateItems(),
'participationScienceProjects' => $generateItems(),
'publications' => $generateItems(),
'contactEmail' => $this->faker->unique()->safeEmail,
'contactPhone' => $this->faker->phoneNumber,
+3 -1
View File
@@ -2,14 +2,16 @@
namespace Database\Factories;
use App\Containers\User\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Containers\User\Models\User>
*/
class UserFactory extends Factory
{
protected $model = User::class;
/**
* Define the model's default state.
*