where('tenant_id', $tenantId) ->where('name', '주일기업 기획') ->whereNull('parent_id') ->first(); if ($existingParent) { $this->command->info('주일기업 기획 메뉴가 이미 존재합니다.'); return; } // 최상위 메뉴 중 가장 큰 sort_order 찾기 $maxSortOrder = Menu::withoutGlobalScopes() ->where('tenant_id', $tenantId) ->whereNull('parent_id') ->max('sort_order') ?? 0; // 대분류 메뉴 생성 $parent = Menu::create([ 'tenant_id' => $tenantId, 'parent_id' => null, 'name' => '주일기업 기획', 'url' => null, 'icon' => 'building-2', 'sort_order' => $maxSortOrder + 1, 'is_active' => true, ]); $this->command->info("대분류 메뉴 생성: 주일기업 기획 (sort_order: {$parent->sort_order})"); // 하위 메뉴 1: 견적/입찰/공사관리 $menu1 = Menu::create([ 'tenant_id' => $tenantId, 'parent_id' => $parent->id, 'name' => '견적/입찰/공사관리', 'url' => '/juil/estimate', 'icon' => 'clipboard-list', 'sort_order' => 1, 'is_active' => true, ]); $this->command->info("하위 메뉴 생성: {$menu1->name} ({$menu1->url})"); // 하위 메뉴 2: 프로젝트관리/기성청구 $menu2 = Menu::create([ 'tenant_id' => $tenantId, 'parent_id' => $parent->id, 'name' => '프로젝트관리/기성청구', 'url' => '/juil/project', 'icon' => 'hard-hat', 'sort_order' => 2, 'is_active' => true, ]); $this->command->info("하위 메뉴 생성: {$menu2->name} ({$menu2->url})"); // 결과 출력 $this->command->info(''); $this->command->info('=== 주일기업 기획 메뉴 구조 ==='); $this->command->info("📁 {$parent->name} (id: {$parent->id})"); $this->command->info(" ├─ {$menu1->name} → {$menu1->url}"); $this->command->info(" └─ {$menu2->name} → {$menu2->url}"); } }