Restore local changes after Git corruption

This commit is contained in:
root
2026-01-10 07:00:36 +00:00
parent 395bfa5e75
commit 915b4fe95d
20 changed files with 1453 additions and 75 deletions

View File

@@ -29,6 +29,7 @@ class UserFactory extends Factory
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'custom_field' => 'user',
];
}

View File

@@ -11,16 +11,19 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('components', function (Blueprint $table) {
$table->id();
$table->string('name'); // Например: "Intel Core i5-12400F"
$table->foreignId('component_type_id')->constrained()->onDelete('cascade');
$table->decimal('price', 10, 2);
$table->json('specifications')->nullable(); // Для хранения характеристик
$table->boolean('is_official')->default(true); // true = админ, false = пользователь
$table->foreignId('created_by_user_id')->nullable()->constrained('users')->onDelete('set null');
$table->timestamps();
});
Schema::create('components', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->decimal('price', 10, 2);
$table->unsignedBigInteger('component_type_id'); // ссылка на тип компонента
$table->json('specifications')->nullable(); // JSON-поле для характеристик
$table->boolean('is_official')->default(false); // официальный или нет
$table->unsignedBigInteger('created_by_user_id')->nullable(); // кто создал
$table->timestamps();
$table->foreign('component_type_id')->references('id')->on('component_types');
$table->foreign('created_by_user_id')->references('id')->on('users')->onDelete('set null');
});
}

View File

@@ -12,7 +12,7 @@ return new class extends Migration
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->text('custom_field');
$table->text('custom_field')->nullable()->default(null);
//
});
}

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePcBuildComponentsTable extends Migration
{
public function up()
{
Schema::create('pc_build_components', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('pc_build_id');
$table->unsignedBigInteger('component_id');
$table->timestamps();
// Внешние ключи
$table->foreign('pc_build_id')->references('id')->on('pc_builds')->onDelete('cascade');
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
// Уникальность пары (build + component), если нужно
$table->unique(['pc_build_id', 'component_id']);
});
}
public function down()
{
Schema::dropIfExists('pc_build_components');
}
}

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::create('ai_tasks', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('description');
$table->text('ai_prompt_template');
$table->decimal('budget_min', 10, 2)->nullable();
$table->decimal('budget_max', 10, 2)->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('ai_tasks');
}
};

View File

@@ -0,0 +1,326 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ComponentSeeder extends Seeder
{
public function run()
{
// 1. Удаляем дочерние таблицы СНАЧАЛА
DB::table('components')->delete();
DB::table('ai_tasks')->delete();
// 2. Теперь можно удалить родительскую таблицу
DB::table('component_types')->delete();
// 3. Вставляем типы с фиксированными ID
$componentTypes = [
['id' => 1, 'name' => 'Процессор', 'code' => 'cpu'],
['id' => 2, 'name' => 'Видеокарта', 'code' => 'gpu'],
['id' => 3, 'name' => 'Материнская плата', 'code' => 'motherboard'],
['id' => 4, 'name' => 'ОЗУ', 'code' => 'ram'],
['id' => 5, 'name' => 'Блок питания', 'code' => 'psu'],
['id' => 6, 'name' => 'SSD', 'code' => 'ssd'],
['id' => 7, 'name' => 'Корпус', 'code' => 'case'],
['id' => 8, 'name' => 'Охлаждение', 'code' => 'cooling'],
['id' => 9, 'name' => 'Сеть', 'code' => 'network'],
['id' => 10, 'name' => 'Звуковая карта', 'code' => 'sound']
];
DB::table('component_types')->insert($componentTypes);
// 2. Добавляем 25 официальных компонентов
$components = [
// Процессоры (ID=1)
[
'name' => 'AMD Ryzen 5 5600',
'price' => 15000,
'component_type_id' => 1,
'specifications' => json_encode(['socket' => 'AM4', 'cores' => 6, 'tdp' => 65]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'AMD Ryzen 7 7700X',
'price' => 25000,
'component_type_id' => 1,
'specifications' => json_encode(['socket' => 'AM5', 'cores' => 8, 'tdp' => 105]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'Intel Core i5-13400F',
'price' => 18000,
'component_type_id' => 1,
'specifications' => json_encode(['socket' => 'LGA1700', 'cores' => 10, 'tdp' => 65]),
'is_official' => true,
'created_by_user_id' => null
],
// Видеокарты (ID=2)
[
'name' => 'NVIDIA RTX 4060',
'price' => 30000,
'component_type_id' => 2,
'specifications' => json_encode(['memory_size' => '8GB', 'gpu_clock_speed' => 2445]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'NVIDIA RTX 4070 Ti',
'price' => 45000,
'component_type_id' => 2,
'specifications' => json_encode(['memory_size' => '12GB', 'gpu_clock_speed' => 2610]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'AMD Radeon RX 7800 XT',
'price' => 40000,
'component_type_id' => 2,
'specifications' => json_encode(['memory_size' => '16GB', 'gpu_clock_speed' => 2200]),
'is_official' => true,
'created_by_user_id' => null
],
// Материнские платы (ID=3)
[
'name' => 'ASUS TUF GAMING B660M-PLUS',
'price' => 8000,
'component_type_id' => 3,
'specifications' => json_encode(['chipset' => 'B660', 'form_factor' => 'mATX']),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'MSI B750 TOMAHAWK',
'price' => 12000,
'component_type_id' => 3,
'specifications' => json_encode(['chipset' => 'B750', 'form_factor' => 'ATX']),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'Gigabyte X670E AORUS PRO',
'price' => 15000,
'component_type_id' => 3,
'specifications' => json_encode(['chipset' => 'X670E', 'form_factor' => 'ATX']),
'is_official' => true,
'created_by_user_id' => null
],
// ОЗУ (ID=4)
[
'name' => 'Kingston FURY Beast DDR4 16GB',
'price' => 5000,
'component_type_id' => 4,
'specifications' => json_encode(['type' => 'DDR4', 'capacity' => '16GB', 'speed' => 3200]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'Corsair Vengeance RGB Pro 32GB DDR5-6000',
'price' => 15000,
'component_type_id' => 4,
'specifications' => json_encode(['type' => 'DDR5', 'capacity' => '32GB', 'speed' => 6000]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'G.Skill Trident Z5 32GB DDR5-6000',
'price' => 16000,
'component_type_id' => 4,
'specifications' => json_encode(['type' => 'DDR5', 'capacity' => '32GB', 'speed' => 6000]),
'is_official' => true,
'created_by_user_id' => null
],
// Блоки питания (ID=5)
[
'name' => 'EVGA SuperNOVA 750 G2',
'price' => 8000,
'component_type_id' => 5,
'specifications' => json_encode(['wattage' => 750, 'efficiency' => '80+ Gold']),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'Seasonic FOCUS GX-850',
'price' => 10000,
'component_type_id' => 5,
'specifications' => json_encode(['wattage' => 850, 'efficiency' => '80+ Gold']),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'Corsair RM850x',
'price' => 12000,
'component_type_id' => 5,
'specifications' => json_encode(['wattage' => 850, 'efficiency' => '80+ Gold']),
'is_official' => true,
'created_by_user_id' => null
],
// SSD (ID=6)
[
'name' => 'Samsung 980 PRO 1TB',
'price' => 10000,
'component_type_id' => 6,
'specifications' => json_encode(['interface' => 'NVMe PCIe 4.0 x4', 'capacity' => 1000]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'Crucial P3 500GB NVMe',
'price' => 4000,
'component_type_id' => 6,
'specifications' => json_encode(['interface' => 'NVMe PCIe 3.0 x4', 'capacity' => 500]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'WD Black SN850X 1TB',
'price' => 12000,
'component_type_id' => 6,
'specifications' => json_encode(['interface' => 'NVMe PCIe 4.0 x4', 'capacity' => 1000]),
'is_official' => true,
'created_by_user_id' => null
],
// Корпуса (ID=7)
[
'name' => 'Cooler Master H500P ATX Mid Tower Case',
'price' => 4000,
'component_type_id' => 7,
'specifications' => json_encode(['form_factor' => 'ATX', 'cooling_type' => 'Air']),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'be quiet! Dark Base Pro 9',
'price' => 12000,
'component_type_id' => 7,
'specifications' => json_encode(['form_factor' => 'ATX', 'max_power' => 800]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'Fractal Design Pop Air',
'price' => 5000,
'component_type_id' => 7,
'specifications' => json_encode(['form_factor' => 'ATX', 'cooling_type' => 'Air']),
'is_official' => true,
'created_by_user_id' => null
],
// Охлаждение (ID=8)
[
'name' => 'Noctua NH-D15',
'price' => 7000,
'component_type_id' => 8,
'specifications' => json_encode(['type' => 'Air', 'tdp' => 200]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'Deepcool Assassin III',
'price' => 5000,
'component_type_id' => 8,
'specifications' => json_encode(['type' => 'Air', 'tdp' => 150]),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'AIO Corsair iCUE H150i ELITE CAPELLIX',
'price' => 15000,
'component_type_id' => 8,
'specifications' => json_encode(['type' => 'Liquid', 'radiator_size' => '360mm']),
'is_official' => true,
'created_by_user_id' => null
],
// Сеть (ID=9)
[
'name' => 'TP-Link Archer TX50E',
'price' => 3000,
'component_type_id' => 9,
'specifications' => json_encode(['interface' => 'Wi-Fi 6', 'speed' => '2.5Gbps']),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'Intel I225-V',
'price' => 2000,
'component_type_id' => 9,
'specifications' => json_encode(['interface' => 'Ethernet', 'speed' => '2.5Gbps']),
'is_official' => true,
'created_by_user_id' => null
],
// Звуковые карты (ID=10)
[
'name' => 'Creative Sound Blaster Z',
'price' => 8000,
'component_type_id' => 10,
'specifications' => json_encode(['interface' => 'PCIe', 'sample_rate' => '192kHz']),
'is_official' => true,
'created_by_user_id' => null
],
[
'name' => 'ASUS Xonar SE',
'price' => 5000,
'component_type_id' => 10,
'specifications' => json_encode(['interface' => 'PCIe', 'sample_rate' => '96kHz']),
'is_official' => true,
'created_by_user_id' => null
]
];
foreach ($components as $component) {
DB::table('components')->insert($component);
}
// 3. Добавляем 4 задачи в ai_tasks
// 3. Добавляем 4 задачи в ai_tasks
$aiTasks = [
[
'user_id' => null,
'name' => 'Игровая сборка до 80000 рублей',
'prompt_template' => 'Подобрать оптимальную сборку для игр в 1080p до 80000 рублей.',
'is_active' => true,
'created_at' => now(),
'updated_at' => now()
],
[
'user_id' => null,
'name' => 'Офисная сборка до 30000 рублей',
'prompt_template' => 'Подобрать бюджетную сборку для офисных задач и интернета.',
'is_active' => true,
'created_at' => now(),
'updated_at' => now()
],
[
'user_id' => null,
'name' => 'Рабочая станция для видеомонтажа',
'prompt_template' => 'Подобрать мощную сборку для редактирования 4K видео.',
'is_active' => true,
'created_at' => now(),
'updated_at' => now()
],
[
'user_id' => null,
'name' => 'Игровая сборка до 1500$',
'prompt_template' => 'Подобрать топовую сборку для игр в 4K до 1500$.',
'is_active' => true,
'created_at' => now(),
'updated_at' => now()
]
];
foreach ($aiTasks as $task) {
DB::table('ai_tasks')->insert($task);
}
}
}

View File

@@ -8,13 +8,13 @@ use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call(ComponentSeeder::class);
// User::factory(10)->create();
User::factory()->create([