fix(item-master): ItemPageService에서 삭제된 sections 관계 참조 제거

- store(): 신규 페이지에 빈 sections 배열 설정
- update(): 섹션 로딩 제거 (수정 시 섹션 변경 없음)
- index(): FK 기반 eager loading 제거
- 섹션 포함 전체 데이터는 init API 사용
This commit is contained in:
2025-11-27 16:20:55 +09:00
parent efa2a84d2c
commit 29dd554bbb

View File

@@ -15,29 +15,25 @@ class ItemPageService extends Service
use LockCheckTrait;
/**
* 페이지 목록 조회 (섹션/필드 중첩)
* 페이지 목록 조회
*
* 섹션/필드 중첩 데이터는 init API 사용 권장
*/
public function index(?string $itemType = null): Collection
{
$tenantId = $this->tenantId();
$query = ItemPage::with([
'sections' => function ($query) {
$query->orderBy('order_no');
},
'sections.fields' => function ($query) {
$query->orderBy('order_no');
},
'sections.bomItems',
])
->where('tenant_id', $tenantId)
$query = ItemPage::where('tenant_id', $tenantId)
->where('is_active', 1);
if ($itemType) {
$query->where('item_type', strtoupper($itemType));
}
return $query->get();
// 각 페이지에 빈 sections 배열 설정 (호환성)
return $query->get()->each(function ($page) {
$page->setAttribute('sections', []);
});
}
/**
@@ -57,8 +53,8 @@ public function store(array $data): ItemPage
'created_by' => $userId,
]);
// 관계 로드
$page->load(['sections']);
// 신규 페이지는 섹션이 없으므로 빈 배열 설정
$page->setAttribute('sections', []);
return $page;
}
@@ -85,7 +81,8 @@ public function update(int $id, array $data): ItemPage
'updated_by' => $userId,
]);
$page->load(['sections.fields', 'sections.bomItems']);
// 페이지 수정은 섹션에 영향 없음 - entity_relationships 기반 조회는 init API 사용
$page->setAttribute('sections', []);
return $page;
}