31 lines
724 B
PHP
31 lines
724 B
PHP
<?php
|
||
|
||
namespace App\Models;
|
||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
use Illuminate\Database\Eloquent\Model;
|
||
|
||
class PcBuild extends Model
|
||
{
|
||
use HasFactory;
|
||
|
||
protected $fillable = [
|
||
'name',
|
||
'description',
|
||
'user_id',
|
||
'is_ai_generated',
|
||
'ai_prompt',
|
||
];
|
||
|
||
// 👇 Связь "многие-ко-многим" с компонентами
|
||
public function components()
|
||
{
|
||
return $this->belongsToMany(Component::class, 'pc_build_components');
|
||
}
|
||
|
||
// Если хотите, можно добавить обратную связь (опционально)
|
||
public function user()
|
||
{
|
||
return $this->belongsTo(User::class);
|
||
}
|
||
} |