fix(item-master): EntityRelationship::link() 파라미터 순서 및 관계 로드 오류 수정

- EntityRelationship::link() 호출 파라미터 순서 수정 (3개 파일)
  - ItemSectionService: tenantId를 첫 번째 파라미터로 변경
  - ItemBomItemService: tenantId를 첫 번째 파라미터로 변경
  - ItemFieldService: tenantId를 첫 번째 파라미터로 변경

- ItemSection 모델의 fields()/bomItems() 관계 메서드 문제 해결
  - 쿼리빌더 반환으로 인한 addEagerConstraints() 에러 수정
  - loadRelatedEntities() 메서드 신규 추가
  - with()/load() 대신 setRelation()으로 데이터 설정

- 영향받은 서비스 파일 전체 수정
  - ItemSectionService, SectionTemplateService, ItemMasterService
This commit is contained in:
2025-11-27 16:49:36 +09:00
parent 29dd554bbb
commit c5eee5561f
6 changed files with 46 additions and 35 deletions

View File

@@ -57,19 +57,18 @@ public function scopeNonTemplates($query)
];
/**
* 섹션에 연결된 필드 목록 (entity_relationships 기반)
* 관련 엔티티(fields, bomItems) 로드
*
* entity_relationships 기반이므로 일반 Eloquent load() 대신 사용
*
* @return $this
*/
public function fields()
public function loadRelatedEntities(): self
{
return $this->linkedFields();
}
$this->setRelation('fields', $this->linkedFields()->orderBy('order_no')->get());
$this->setRelation('bomItems', $this->linkedBomItems()->orderBy('id')->get());
/**
* 섹션에 연결된 BOM 항목 목록 (entity_relationships 기반)
*/
public function bomItems()
{
return $this->linkedBomItems();
return $this;
}
/**