From 625a6ccf694c3cc9b21e9b3cd68ccccd03eed608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Mon, 9 Feb 2026 12:32:26 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EC=84=9C=EB=B2=84=20=EB=A9=94=EB=89=B4=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B6=88=EC=9D=BC=EC=B9=98=20=EB=B3=B4?= =?UTF-8?q?=EC=A0=95=20=EC=8B=9C=EB=8D=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 서버 DB의 메뉴 이름(미수금 관리, 미지급금 관리, 환불/해지 관리)이 로컬과 달라 이동되지 않은 3개 메뉴를 고객/거래처/채권관리로 이동 Co-Authored-By: Claude Opus 4.6 --- database/seeders/FixServerMenuSeeder.php | 107 +++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 database/seeders/FixServerMenuSeeder.php diff --git a/database/seeders/FixServerMenuSeeder.php b/database/seeders/FixServerMenuSeeder.php new file mode 100644 index 00000000..4560a0d5 --- /dev/null +++ b/database/seeders/FixServerMenuSeeder.php @@ -0,0 +1,107 @@ +where('tenant_id', $tenantId) + ->where('name', '고객/거래처/채권관리') + ->whereNull('parent_id') + ->first(); + + if (!$targetGroup) { + $this->command->error('고객/거래처/채권관리 그룹을 찾을 수 없습니다.'); + return; + } + + $this->command->info("대상 그룹: 고객/거래처/채권관리 (id: {$targetGroup->id})"); + + // 서버에서 실제 메뉴 이름으로 이동 (로컬과 서버 모두 대응) + $menuMoves = [ + // [검색 이름들, 새 이름, sort_order] + [['채권관리', '미수금 관리', '미수금관리'], '미수금관리', 3], + [['채무관리', '미지급금 관리', '미지급금관리'], '미지급금관리', 4], + [['환불관리', '환불/해지 관리', '환불/해지관리'], '환불/해지관리', 5], + ]; + + foreach ($menuMoves as [$searchNames, $newName, $sortOrder]) { + $menu = null; + foreach ($searchNames as $name) { + $menu = Menu::withoutGlobalScopes() + ->where('tenant_id', $tenantId) + ->where('name', $name) + ->where('is_active', true) + ->first(); + if ($menu) break; + } + + if (!$menu) { + // 이미 이동된 경우 확인 + $existing = Menu::withoutGlobalScopes() + ->where('tenant_id', $tenantId) + ->where('parent_id', $targetGroup->id) + ->where('name', $newName) + ->first(); + + if ($existing) { + $this->command->info(" 이미 이동됨: {$newName} (id: {$existing->id})"); + } else { + $this->command->warn(" 메뉴 없음: " . implode(' / ', $searchNames)); + } + continue; + } + + $menu->update([ + 'parent_id' => $targetGroup->id, + 'sort_order' => $sortOrder, + 'name' => $newName, + ]); + $this->command->info(" 이동: {$menu->getOriginal('name')} → 고객/거래처/채권관리/{$newName} (sort: {$sortOrder})"); + } + + // 재무관리 부모 비활성화 (자식 없으면) + $financeParent = Menu::withoutGlobalScopes() + ->where('tenant_id', $tenantId) + ->where('name', '재무관리') + ->whereNull('parent_id') + ->first(); + + if ($financeParent) { + $remaining = Menu::withoutGlobalScopes() + ->where('tenant_id', $tenantId) + ->where('parent_id', $financeParent->id) + ->where('is_active', true) + ->count(); + + if ($remaining === 0) { + $financeParent->update(['is_active' => false]); + $this->command->info(" 비활성화: 재무관리 (id: {$financeParent->id})"); + } else { + $this->command->warn(" 재무관리 자식 {$remaining}개 남음 - 비활성화 안 함"); + } + } + + // 결과 확인 + $this->command->info(''); + $this->command->info('=== 고객/거래처/채권관리 최종 구성 ==='); + $children = Menu::withoutGlobalScopes() + ->where('tenant_id', $tenantId) + ->where('parent_id', $targetGroup->id) + ->where('is_active', true) + ->orderBy('sort_order') + ->get(['name', 'url', 'sort_order']); + + foreach ($children as $child) { + $this->command->info(" {$child->sort_order}. {$child->name} → {$child->url}"); + } + } +}