feat(board): 게시판 수정 시 메뉴 URL/이름 자동 업데이트

- MenuService::updateMenuForBoard() 메서드 추가
- 시스템 게시판: global_menus + 연결된 모든 menus URL 업데이트
- 테넌트 게시판: 해당 테넌트의 menus만 URL 업데이트
- BoardService::updateAnyBoard()에서 board_code/name 변경 감지 시 호출

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-28 00:17:53 +09:00
parent 12f5d9e280
commit 5d96ff871d
2 changed files with 85 additions and 4 deletions

View File

@@ -406,10 +406,17 @@ public function getAllBoards(array $filters = [], int $perPage = 15): LengthAwar
->withCount('fields')
->withTrashed();
// 테넌트 필터: 선택 없으면 시스템만, 선택하면 해당 테넌트
if (! empty($filters['tenant_id'])) {
$query->where('tenant_id', $filters['tenant_id']);
// 헤더에서 선택한 테넌트 기준: 시스템 게시판 + 해당 테넌트 게시판
$selectedTenantId = session('selected_tenant_id');
if ($selectedTenantId && $selectedTenantId !== 'all') {
// 시스템 게시판 + 선택된 테넌트 게시판
$query->where(function ($q) use ($selectedTenantId) {
$q->where('is_system', true)
->orWhere('tenant_id', $selectedTenantId);
});
} else {
// 전체 보기: 시스템 게시판만 (테넌트 게시판은 테넌트 선택 후 표시)
$query->where('is_system', true);
}
@@ -499,12 +506,32 @@ public function updateAnyBoard(int $id, array $data): bool
{
$board = Board::findOrFail($id);
// 기존 값 저장 (메뉴 업데이트용)
$oldCode = $board->board_code;
$oldName = $board->name;
$data['updated_by'] = auth()->id();
// tenant_id 변경 방지 (시스템 ↔ 테넌트 전환 불가)
unset($data['tenant_id'], $data['is_system']);
return $board->update($data);
$result = $board->update($data);
// board_code 또는 name 변경 시 메뉴도 업데이트
$newCode = $data['board_code'] ?? $oldCode;
$newName = $data['name'] ?? $oldName;
if ($oldCode !== $newCode || $oldName !== $newName) {
$this->menuService->updateMenuForBoard(
$oldCode,
$newCode,
$newName,
$board->is_system,
$board->tenant_id
);
}
return $result;
}
/**