feat(board): 본사(HQ) 테넌트만 시스템 게시판 표시 및 우선 정렬
- 본사(tenant_type=HQ) 선택 시: 시스템 게시판 + 본사 게시판 표시 - 일반 테넌트 선택 시: 해당 테넌트 게시판만 표시 - 정렬: is_system DESC 추가 (시스템 게시판 우선) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -406,15 +406,25 @@ public function getAllBoards(array $filters = [], int $perPage = 15): LengthAwar
|
||||
->withCount(['fields', 'posts'])
|
||||
->withTrashed();
|
||||
|
||||
// 헤더에서 선택한 테넌트 기준: 시스템 게시판 + 해당 테넌트 게시판
|
||||
// 헤더에서 선택한 테넌트 기준
|
||||
$selectedTenantId = session('selected_tenant_id');
|
||||
|
||||
if ($selectedTenantId && $selectedTenantId !== 'all') {
|
||||
// 시스템 게시판 + 선택된 테넌트 게시판
|
||||
$query->where(function ($q) use ($selectedTenantId) {
|
||||
$q->where('is_system', true)
|
||||
->orWhere('tenant_id', $selectedTenantId);
|
||||
});
|
||||
// 선택된 테넌트가 본사(HQ)인지 확인
|
||||
$isHQ = Tenant::where('id', $selectedTenantId)
|
||||
->where('tenant_type', 'HQ')
|
||||
->exists();
|
||||
|
||||
if ($isHQ) {
|
||||
// 본사: 시스템 게시판 + 본사 테넌트 게시판
|
||||
$query->where(function ($q) use ($selectedTenantId) {
|
||||
$q->where('is_system', true)
|
||||
->orWhere('tenant_id', $selectedTenantId);
|
||||
});
|
||||
} else {
|
||||
// 일반 테넌트: 해당 테넌트 게시판만 (시스템 게시판 제외)
|
||||
$query->where('tenant_id', $selectedTenantId);
|
||||
}
|
||||
} else {
|
||||
// 전체 보기: 시스템 게시판만 (테넌트 게시판은 테넌트 선택 후 표시)
|
||||
$query->where('is_system', true);
|
||||
@@ -449,10 +459,11 @@ public function getAllBoards(array $filters = [], int $perPage = 15): LengthAwar
|
||||
}
|
||||
}
|
||||
|
||||
// 정렬
|
||||
// 정렬: 시스템 게시판 우선, 그 다음 사용자 지정 정렬
|
||||
$sortBy = $filters['sort_by'] ?? 'id';
|
||||
$sortDirection = $filters['sort_direction'] ?? 'desc';
|
||||
$query->orderBy($sortBy, $sortDirection);
|
||||
$query->orderBy('is_system', 'desc') // 시스템 게시판 우선
|
||||
->orderBy($sortBy, $sortDirection);
|
||||
|
||||
return $query->paginate($perPage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user