argument('identifier'); try { if ($identifier) { return $this->refreshSingle($identifier); } return $this->refreshAll(); } catch (\Exception $e) { $this->error('❌ '.$e->getMessage()); Log::error('템플릿 레이아웃 갱신 실패', [ 'template' => $identifier ?? 'all', 'error' => $e->getMessage(), ]); return Command::FAILURE; } } /** * 특정 템플릿의 레이아웃을 갱신합니다. */ private function refreshSingle(string $identifier): int { $this->info("템플릿 '{$identifier}' 레이아웃 갱신 중..."); $result = $this->templateService->refreshTemplateLayouts($identifier); if ($result) { $this->info("✅ 템플릿 '{$identifier}' 레이아웃 갱신 완료"); Log::info('템플릿 레이아웃 갱신 완료', ['template' => $identifier]); return Command::SUCCESS; } $this->error("❌ 템플릿 '{$identifier}' 레이아웃 갱신 실패"); return Command::FAILURE; } /** * 모든 활성 템플릿의 레이아웃을 갱신합니다. */ private function refreshAll(): int { $templates = Template::where('status', 'active')->pluck('identifier')->toArray(); if (empty($templates)) { $this->line('활성화된 템플릿이 없습니다.'); return Command::SUCCESS; } $this->info('모든 활성 템플릿 레이아웃 갱신 중...'); $successCount = 0; $failCount = 0; foreach ($templates as $templateIdentifier) { $this->line(" {$templateIdentifier} 갱신 중..."); try { $result = $this->templateService->refreshTemplateLayouts($templateIdentifier); if ($result) { $this->info(" ✅ {$templateIdentifier} 완료"); $successCount++; } else { $this->warn(" ⚠️ {$templateIdentifier} 실패"); $failCount++; } } catch (\Exception $e) { $this->warn(" ⚠️ {$templateIdentifier}: ".$e->getMessage()); $failCount++; } } $this->newLine(); $this->info("✅ 총 {$successCount}개 성공, {$failCount}개 실패"); Log::info('템플릿 레이아웃 일괄 갱신 완료', [ 'success' => $successCount, 'failed' => $failCount, ]); return $failCount > 0 ? Command::FAILURE : Command::SUCCESS; } }