fix:인터뷰 시나리오 메뉴를 모든 테넌트에 추가

- 기존: tenant_id=1에만 메뉴 생성
- 수정: 글로벌(null) + 모든 테넌트의 영업관리 하위에 생성

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-06 21:09:02 +09:00
parent a507f7dc69
commit d0e4a8e6a2

View File

@@ -9,49 +9,51 @@ class InterviewMenuSeeder extends Seeder
{
public function run(): void
{
$tenantId = 1;
// 영업관리 상위 메뉴 찾기
$salesParentId = Menu::where('tenant_id', $tenantId)
// 모든 테넌트의 영업관리 메뉴 찾기 (글로벌 포함)
$salesMenus = Menu::withoutGlobalScopes()
->where('name', '영업관리')
->whereNull('parent_id')
->value('id');
->whereNull('deleted_at')
->get();
if (!$salesParentId) {
if ($salesMenus->isEmpty()) {
$this->command->error('영업관리 메뉴를 찾을 수 없습니다.');
return;
}
// 이미 존재하는지 확인
$exists = Menu::where('tenant_id', $tenantId)
->where('parent_id', $salesParentId)
->where('name', '인터뷰 시나리오')
->exists();
foreach ($salesMenus as $salesMenu) {
$tenantId = $salesMenu->tenant_id;
$label = $tenantId ? "tenant_id={$tenantId}" : 'global(tenant_id=null)';
if ($exists) {
$this->command->info('인터뷰 시나리오 메뉴가 이미 존재합니다.');
return;
// 이미 존재하는지 확인
$exists = Menu::withoutGlobalScopes()
->where('parent_id', $salesMenu->id)
->where('name', '인터뷰 시나리오')
->whereNull('deleted_at')
->exists();
if ($exists) {
$this->command->info("[{$label}] 인터뷰 시나리오 메뉴가 이미 존재합니다.");
continue;
}
// 마지막 sort_order 확인
$maxSort = Menu::withoutGlobalScopes()
->where('parent_id', $salesMenu->id)
->whereNull('deleted_at')
->max('sort_order') ?? 0;
Menu::withoutGlobalScopes()->create([
'tenant_id' => $tenantId,
'parent_id' => $salesMenu->id,
'name' => '인터뷰 시나리오',
'url' => '/sales/interviews',
'icon' => 'clipboard-check',
'sort_order' => $maxSort + 1,
'is_active' => true,
]);
$this->command->info("[{$label}] 인터뷰 시나리오 메뉴 생성 완료.");
}
// 영업파트너 승인 메뉴의 sort_order 확인
$approvalMenu = Menu::where('tenant_id', $tenantId)
->where('parent_id', $salesParentId)
->where('name', '영업파트너 승인')
->first();
$sortOrder = $approvalMenu ? $approvalMenu->sort_order + 1 : 10;
// 인터뷰 시나리오 메뉴 생성
Menu::create([
'tenant_id' => $tenantId,
'parent_id' => $salesParentId,
'name' => '인터뷰 시나리오',
'url' => '/sales/interviews',
'icon' => 'clipboard-check',
'sort_order' => $sortOrder,
'is_active' => true,
]);
$this->command->info('인터뷰 시나리오 메뉴가 생성되었습니다.');
}
}