From 5ab5353d4d12ea2bd8bccc5604312ab4e8bab803 Mon Sep 17 00:00:00 2001 From: kent Date: Fri, 26 Dec 2025 13:49:43 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20ItemPage=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EC=8B=9C=20source=5Ftable=20=EC=9E=90=EB=8F=99=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - store() 메서드에서 item_type으로 common_codes.attributes의 source_table 조회 - getSourceTableFromCommonCode() 헬퍼 메서드 추가 - 기존 source_table이 null인 레코드 수정 (tenant_id=288의 CS, RM) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/Services/ItemMaster/ItemPageService.php | 26 ++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/Services/ItemMaster/ItemPageService.php b/app/Services/ItemMaster/ItemPageService.php index 3bc51e9..db9ed7f 100644 --- a/app/Services/ItemMaster/ItemPageService.php +++ b/app/Services/ItemMaster/ItemPageService.php @@ -43,11 +43,16 @@ public function store(array $data): ItemPage { $tenantId = $this->tenantId(); $userId = $this->apiUserId(); + $itemType = strtoupper($data['item_type']); + + // item_type으로 common_codes에서 source_table 조회 + $sourceTable = $this->getSourceTableFromCommonCode($itemType); $page = ItemPage::create([ 'tenant_id' => $tenantId, 'page_name' => $data['page_name'], - 'item_type' => $data['item_type'], + 'item_type' => $itemType, + 'source_table' => $sourceTable, 'absolute_path' => $data['absolute_path'] ?? null, 'is_active' => true, 'created_by' => $userId, @@ -127,4 +132,23 @@ public function destroy(int $id): void $page->update(['deleted_by' => $userId]); $page->delete(); } + + /** + * item_type에 해당하는 source_table을 common_codes.attributes에서 조회 + */ + private function getSourceTableFromCommonCode(string $itemType): ?string + { + $commonCode = \DB::table('common_codes') + ->where('code_group', 'item_type') + ->where('code', strtoupper($itemType)) + ->first(); + + if (! $commonCode || ! $commonCode->attributes) { + return null; + } + + $attrs = json_decode($commonCode->attributes, true); + + return $attrs['source_table'] ?? null; + } }