feat: Item Master 하이브리드 구조 전환 및 독립 API 추가
- CASCADE FK → 독립 엔티티 + entity_relationships 링크 테이블 - 독립 API 10개 추가 (섹션/필드/BOM CRUD, clone, usage) - SectionTemplate 모델 제거 → ItemSection.is_template 통합 - 페이지-섹션, 섹션-필드, 섹션-BOM 링크/언링크 API 14개 추가 - Swagger 문서 업데이트
This commit is contained in:
@@ -13,6 +13,7 @@ class ItemField extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'group_id',
|
||||
'section_id',
|
||||
'field_name',
|
||||
'field_type',
|
||||
@@ -30,6 +31,7 @@ class ItemField extends Model
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'group_id' => 'integer',
|
||||
'order_no' => 'integer',
|
||||
'is_required' => 'boolean',
|
||||
'display_condition' => 'array',
|
||||
@@ -47,10 +49,47 @@ class ItemField extends Model
|
||||
];
|
||||
|
||||
/**
|
||||
* 소속 섹션
|
||||
* 소속 섹션 (기존 FK 기반 - 하위 호환성)
|
||||
*/
|
||||
public function section()
|
||||
{
|
||||
return $this->belongsTo(ItemSection::class, 'section_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 이 필드가 연결된 섹션들 조회 (링크 테이블 기반)
|
||||
*/
|
||||
public function linkedSections()
|
||||
{
|
||||
return ItemSection::whereIn('id', function ($query) {
|
||||
$query->select('parent_id')
|
||||
->from('entity_relationships')
|
||||
->where('parent_type', EntityRelationship::TYPE_SECTION)
|
||||
->where('child_type', EntityRelationship::TYPE_FIELD)
|
||||
->where('child_id', $this->id);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 이 필드가 직접 연결된 페이지들 조회 (링크 테이블 기반)
|
||||
*/
|
||||
public function linkedPages()
|
||||
{
|
||||
return ItemPage::whereIn('id', function ($query) {
|
||||
$query->select('parent_id')
|
||||
->from('entity_relationships')
|
||||
->where('parent_type', EntityRelationship::TYPE_PAGE)
|
||||
->where('child_type', EntityRelationship::TYPE_FIELD)
|
||||
->where('child_id', $this->id);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 이 필드의 모든 부모 관계 목록 조회
|
||||
*/
|
||||
public function allParentRelationships()
|
||||
{
|
||||
return EntityRelationship::where('child_type', EntityRelationship::TYPE_FIELD)
|
||||
->where('child_id', $this->id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user