Restore local changes after Git corruption
This commit is contained in:
26
app/Models/AiTask.php
Normal file
26
app/Models/AiTask.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AiTask extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'description',
|
||||
'ai_prompt_template',
|
||||
'budget_min',
|
||||
'budget_max',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'budget_min' => 'decimal:2',
|
||||
'budget_max' => 'decimal:2',
|
||||
'is_active' => 'boolean'
|
||||
];
|
||||
}
|
||||
@@ -11,29 +11,24 @@ class Component extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'component_type_id',
|
||||
'price',
|
||||
'component_type_id',
|
||||
'specifications',
|
||||
'is_official',
|
||||
'created_by_user_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'specifications' => 'array', // Автоматически преобразует JSON в массив
|
||||
'is_official' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'specifications' => 'array', // автоматически преобразует JSON в массив
|
||||
];
|
||||
|
||||
// Связь с типом компонента
|
||||
public function type()
|
||||
{
|
||||
return $this->belongsTo(ComponentType::class, 'component_type_id');
|
||||
}
|
||||
|
||||
// Связь с пользователем (если добавил пользователь)
|
||||
public function createdBy()
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by_user_id');
|
||||
}
|
||||
|
||||
public function componentType()
|
||||
{
|
||||
return $this->belongsTo(ComponentType::class, 'component_type_id');
|
||||
}
|
||||
}
|
||||
@@ -10,20 +10,20 @@ class PcBuild extends Model
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'name',
|
||||
'description',
|
||||
'user_id',
|
||||
'is_ai_generated',
|
||||
'ai_prompt',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_ai_generated' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
// 👇 Связь "многие-ко-многим" с компонентами
|
||||
public function components()
|
||||
{
|
||||
return $this->belongsToMany(Component::class, 'pc_build_components');
|
||||
}
|
||||
|
||||
// Связь с пользователем
|
||||
// Если хотите, можно добавить обратную связь (опционально)
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
35
app/Models/PCBuildComponent.php
Normal file
35
app/Models/PCBuildComponent.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PcBuildComponent extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'pc_build_id',
|
||||
'component_id',
|
||||
'quantity',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'quantity' => 'integer',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
// Связь с сборкой
|
||||
public function build()
|
||||
{
|
||||
return $this->belongsTo(PcBuild::class);
|
||||
}
|
||||
|
||||
// Связь с компонентом
|
||||
public function component()
|
||||
{
|
||||
return $this->belongsTo(Component::class);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ class User extends Authenticatable
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'custom_field'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user