first commit

This commit is contained in:
f4ilji
2024-09-19 16:06:49 +05:00
commit b686638a39
1664 changed files with 428174 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Category>
*/
class CategoryFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
// Генерируем случайное количество слов от 1 до 3
$wordCount = rand(1, 3);
$title = $this->faker->words($wordCount, true); // true объединяет слова в строку
$slug = Str::slug($title);
return [
'title' => $title,
'slug' => $slug,
];
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace Database\Factories;
use App\Models\Faculty;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Department>
*/
class DepartmentFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$title = $this->faker->sentence;
$slug = Str::slug($title);
$content = array_map(function () {
return [
'type' => $this->faker->randomElement(['heading', 'paragraph']),
'data' => [
'id' => $this->faker->numberBetween(1, 1000000),
'content' => $this->faker->paragraph,
],
];
}, range(1, $this->faker->numberBetween(1, 5)));
$faculty_id = Faculty::inRandomOrder()->first();
return [
'title' => $title,
'slug' => $slug,
'content' => $content,
'faculty_id' => $faculty_id,
'created_at' => now(),
'updated_at' => now(),
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\EventCategory>
*/
class EventCategoryFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$wordCount = rand(1, 3);
$title = $this->faker->words($wordCount, true); // true объединяет слова в строку
$slug = Str::slug($title);
return [
'title' => $title,
'slug' => $slug,
];
}
}
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace Database\Factories;
use App\Models\EventCategory;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Event>
*/
class EventFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$id = $this->faker->numberBetween(1, 1000000);
$title = $this->faker->sentence;
$slug = Str::slug($title);
$content = array_map(function () {
return [
'type' => $this->faker->randomElement(['heading', 'paragraph']),
'data' => [
'id' => $this->faker->numberBetween(1, 1000000),
'content' => $this->faker->paragraph,
],
];
}, range(1, $this->faker->numberBetween(1, 5)));
$today = now();
$random_days = rand(1, 25); // Генерируем случайное число дней от 1 до 365
$event_date_start = date('Y-m-d', strtotime($today->format('Y-m-d') . ' +' . $random_days . ' days'));
$event_time_start = $this->faker->time('H:i');
$address = $this->faker->address;
$is_online = $this->faker->randomElement([true, false]);
$category_id = EventCategory::inRandomOrder()->first();
$created_at = now();
$updated_at = now();
return [
'id' => $id,
'title' => $title,
'slug' => $slug,
'content' => $content,
'event_date_start' => $event_date_start,
'event_time_start' => $event_time_start,
'address' => $address,
'is_online' => $is_online,
'category_id' => $category_id,
'created_at' => $created_at,
'updated_at' => $updated_at,
];
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Faculty>
*/
class FacultyFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$title = $this->faker->sentence;
$slug = Str::slug($title);
$content = array_map(function () {
return [
'type' => $this->faker->randomElement(['heading', 'paragraph']),
'data' => [
'id' => $this->faker->numberBetween(1, 1000000),
'content' => $this->faker->paragraph,
],
];
}, range(1, $this->faker->numberBetween(1, 5)));
$abbreviation = $this->faker->word;
return [
'title' => $title,
'slug' => $slug,
'content' => $content,
'abbreviation' => $abbreviation,
'created_at' => now(),
'updated_at' => now(),
];
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Page>
*/
class PageFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}
+60
View File
@@ -0,0 +1,60 @@
<?php
namespace Database\Factories;
use App\Models\Category;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Post>
*/
class PostFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$this->faker->addProvider(new \Xvladqt\Faker\LoremFlickrProvider($this->faker));
$title = $this->faker->sentence;
$slug = Str::slug($title);
$content = array_map(function () {
return [
'type' => $this->faker->randomElement(['heading', 'paragraph']),
'data' => [
'id' => $this->faker->numberBetween(1, 1000000),
'content' => $this->faker->paragraph,
],
];
}, range(1, $this->faker->numberBetween(1, 5)));
$status = $this->faker->randomElement(['verification', 'published', 'rejected']);
$authorsCount = $this->faker->numberBetween(1, 5);
$authors = array_fill(0, $authorsCount, $this->faker->name);
$imagesCount = $this->faker->numberBetween(1, 5);
$images = array_fill(0, $imagesCount, $this->faker->uuid . '.jpg');
$category_id = Category::inRandomOrder()->first();
$search_data = $this->faker->words(10, true);
$reading_time = $this->faker->numberBetween(5, 30);
return [
'title' => $title,
'slug' => $slug,
'content' => $content,
'status' => $status,
'authors' => $authors,
'images' => $images,
'search_data' => $search_data,
'reading_time' => $reading_time,
'category_id' => $category_id,
'created_at' => now(),
'updated_at' => now(),
];
}
}
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
*/
class ProgramDepartmentFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
*/
class TeacherDepartmentFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\UserDetail>
*/
class UserDetailFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
// Получаем пользователей, у которых еще нет UserDetail
// Генерация случайного количества наград и других полей
$awardsCount = rand(1, 5);
$awards = [];
for ($i = 0; $i < $awardsCount; $i++) {
$awards[] = ['item' => $this->faker->sentence(6)];
}
$generateItems = function () {
$itemsCount = rand(1, 5); // Случайное число от 1 до 5
$items = [];
for ($i = 0; $i < $itemsCount; $i++) {
$items[] = ['item' => $this->faker->sentence(6)];
}
return $items;
};
return [
'user_id' => null, // Это будет установлено позже
'is_only_worker' => $this->faker->boolean,
'photo' => "images/01J7TKMCR55KY7ARS2DA6VVAHE.jpg",
'academicTitle' => $this->faker->word,
'AcademicDegree' => $this->faker->word,
'education' => $this->faker->sentence,
'awards' => $awards,
'professDisciplines' => $generateItems(),
'professionalRetraining' => $generateItems(),
'professionalDevelopment' => $generateItems(),
'workExperience' => $this->faker->randomDigit(),
'attendedConferences' => $generateItems(),
'participationScienceProjects' => $generateItems(),
'publications' => $generateItems(),
'contactEmail' => $this->faker->unique()->safeEmail,
'contactPhone' => $this->faker->phoneNumber,
];
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* 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' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
*/
class WorkerDepartmentFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'position' => $this->faker->word,
];
}
}
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
*/
class WorkerFacultyFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}