Начальный коммит: рабочая версия с исправленной авторизацией
This commit is contained in:
34
app/Models/Component.php
Normal file
34
app/Models/Component.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user