Files
sam-api/app/Models/ItemMaster/ItemSection.php

61 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace App\Models\ItemMaster;
use App\Traits\BelongsToTenant;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class ItemSection extends Model
{
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $fillable = [
'tenant_id',
'page_id',
'title',
'type',
'order_no',
'created_by',
'updated_by',
'deleted_by',
];
protected $casts = [
'order_no' => 'integer',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
protected $hidden = [
'deleted_by',
'deleted_at',
];
/**
* 소속 페이지
*/
public function page()
{
return $this->belongsTo(ItemPage::class, 'page_id');
}
/**
* 섹션의 필드 목록
*/
public function fields()
{
return $this->hasMany(ItemField::class, 'section_id')->orderBy('order_no');
}
/**
* 섹션의 BOM 항목 목록
*/
public function bomItems()
{
return $this->hasMany(ItemBomItem::class, 'section_id');
}
}