Files
Intelligent-selection-of-co…/app/Models/Component.php
2026-01-10 07:00:36 +00:00

34 lines
733 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Component extends Model
{
use HasFactory;
protected $fillable = [
'name',
'price',
'component_type_id',
'specifications',
'is_official',
'created_by_user_id',
];
protected $casts = [
'specifications' => 'array', // автоматически преобразует JSON в массив
];
public function user()
{
return $this->belongsTo(User::class, 'created_by_user_id');
}
public function componentType()
{
return $this->belongsTo(ComponentType::class, 'component_type_id');
}
}