Files
componentsPC/app/Models/PCBuild.php

55 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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',
];
<<<<<<< HEAD
// 👇 Связь "многие-ко-многим" с компонентами
public function components()
{
return $this->belongsToMany(Component::class, 'pc_build_components');
}
// Обратная связь
=======
protected $casts = [
'is_ai_generated' => 'boolean',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
// Связь с пользователем
>>>>>>> origin/main
public function user()
{
return $this->belongsTo(User::class);
}
<<<<<<< HEAD
// Опционально: защита от ошибок, если сборка без пользователя
protected static function booted()
{
static::addGlobalScope('user', function ($query) {
if (auth()->check()) {
$query->where('user_id', auth()->id());
}
});
}
=======
>>>>>>> origin/main
}