refactor: 회원가입 메뉴 복사 로직을 global_menus 테이블 기반으로 변경

- MenuBootstrapService: menus → global_menus 테이블에서 조회
- MenusStep: 신규 테넌트 부트스트랩 시 global_menus 사용
- GlobalMenuTemplateSeeder: GlobalMenu 모델 사용으로 변경
This commit is contained in:
2025-12-02 22:55:10 +09:00
parent 6b4f02e96e
commit b8e96be56c
3 changed files with 32 additions and 31 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Services;
use App\Models\Commons\GlobalMenu;
use App\Models\Commons\Menu;
use Illuminate\Support\Facades\DB;
@@ -23,10 +24,8 @@ class MenuBootstrapService
public static function cloneGlobalMenusForTenant(int $tenantId): array
{
return DB::transaction(function () use ($tenantId) {
// 1. 활성화된 글로벌 템플릿 메뉴 조회 (parent_id 순서대로 정렬)
$templateMenus = Menu::withoutGlobalScopes()
->whereNull('tenant_id')
->where('is_active', true) // 활성화된 메뉴만 복사
// 1. 활성화된 글로벌 템플릿 메뉴 조회 (global_menus 테이블에서)
$templateMenus = GlobalMenu::where('is_active', true) // 활성화된 메뉴만 복사
->orderByRaw('COALESCE(parent_id, 0)')
->orderBy('sort_order')
->get();
@@ -88,10 +87,8 @@ public static function cloneSingleMenu(int $globalMenuId, int $tenantId, ?int $n
return null;
}
// 글로벌 메뉴 조회
$globalMenu = Menu::withoutGlobalScopes()
->whereNull('tenant_id')
->find($globalMenuId);
// 글로벌 메뉴 조회 (global_menus 테이블에서)
$globalMenu = GlobalMenu::find($globalMenuId);
if (! $globalMenu) {
return null;
@@ -134,10 +131,8 @@ public static function cloneMenuWithChildren(int $globalMenuId, int $tenantId, ?
}
$menuIds[] = $rootMenu->id;
// 2. 하위 메뉴 재귀 복제
$children = Menu::withoutGlobalScopes()
->whereNull('tenant_id')
->where('parent_id', $globalMenuId)
// 2. 하위 메뉴 재귀 복제 (global_menus 테이블에서)
$children = GlobalMenu::where('parent_id', $globalMenuId)
->where('is_active', true)
->orderBy('sort_order')
->get();