35 lines
693 B
PHP
35 lines
693 B
PHP
<?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);
|
||
}
|
||
} |