fix(board): 게시판 URL tenant_id 처리 및 게시글 수 표시 추가
- Route Model Binding → 수동 조회로 변경 (board_code + tenant_id) - PostController: resolveBoard() 헬퍼 추가 - t 파라미터 → 시스템 게시판 → 로그인 회원 tenant 순서 - 사이드바 메뉴 리다이렉트: tenant_id ?? 1 fallback 추가 - SidebarMenuService와 동일한 로직으로 일관성 확보 - 게시판 목록 테이블에 게시글 수 컬럼 추가 - 모든 posts View에 tenant_id 파라미터 추가 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -108,14 +108,14 @@
|
||||
// 고객센터 (활성화된 시스템 게시판 목록)
|
||||
Route::get('/customer-center', [CustomerCenterController::class, 'index'])->name('customer-center.index');
|
||||
|
||||
// 고객센터 게시판 리다이렉트 (board_code → boards/{id}/posts)
|
||||
// 고객센터 게시판 리다이렉트 (board_code → boards/{code}/posts)
|
||||
Route::get('/customer-center/{code}', function (string $code) {
|
||||
$board = \App\Models\Boards\Board::where('board_code', $code)
|
||||
->whereNull('tenant_id')
|
||||
->where('is_active', true)
|
||||
->firstOrFail();
|
||||
|
||||
return redirect()->route('boards.posts.index', $board->id);
|
||||
return redirect()->route('boards.posts.index', $board->board_code);
|
||||
})->name('customer-center.board');
|
||||
|
||||
// 시스템 게시판 관리 (Blade 화면만)
|
||||
@@ -124,25 +124,42 @@
|
||||
Route::get('/create', [BoardController::class, 'create'])->name('create');
|
||||
Route::get('/{id}/edit', [BoardController::class, 'edit'])->name('edit');
|
||||
|
||||
// 테넌트 게시판 리다이렉트 (board_code → boards/{id}/posts)
|
||||
// 사이드바 메뉴에서 접근 시 리다이렉트 (board_code → boards/{boardCode}/posts?t=)
|
||||
// 좌측 메뉴는 로그인 회원의 테넌트 게시판 사용
|
||||
Route::get('/{code}', function (string $code) {
|
||||
// 숫자만 있는 경우 (기존 라우트와 충돌 방지)
|
||||
if (is_numeric($code)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$tenantId = session('selected_tenant_id');
|
||||
// 로그인 회원의 tenant_id 사용 (사이드바 메뉴용)
|
||||
// SidebarMenuService와 동일하게 tenant_id가 null이면 1 사용
|
||||
$userTenantId = auth()->user()?->tenant_id ?? 1;
|
||||
|
||||
// 시스템 게시판 우선, 그 다음 로그인 회원의 테넌트 게시판
|
||||
$board = \App\Models\Boards\Board::where('board_code', $code)
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereNull('tenant_id')
|
||||
->where('is_active', true)
|
||||
->firstOrFail();
|
||||
->first();
|
||||
|
||||
return redirect()->route('boards.posts.index', $board->id);
|
||||
if (! $board) {
|
||||
$board = \App\Models\Boards\Board::where('board_code', $code)
|
||||
->where('tenant_id', $userTenantId)
|
||||
->where('is_active', true)
|
||||
->firstOrFail();
|
||||
}
|
||||
|
||||
// t 파라미터 포함하여 리다이렉트
|
||||
return redirect()->route('boards.posts.index', [
|
||||
'boardCode' => $board->board_code,
|
||||
't' => $board->tenant_id,
|
||||
]);
|
||||
})->name('tenant-board')->where('code', '[a-zA-Z][a-zA-Z0-9_-]*');
|
||||
|
||||
// 게시글 CRUD (board 하위 중첩 라우트)
|
||||
Route::prefix('{board}/posts')->name('posts.')->group(function () {
|
||||
// board_code + tenant_id(query param 't')로 게시판 조회
|
||||
// tenant_id 없으면 로그인 회원의 tenant_id 사용
|
||||
Route::prefix('{boardCode}/posts')->name('posts.')->group(function () {
|
||||
Route::get('/', [PostController::class, 'index'])->name('index');
|
||||
Route::get('/create', [PostController::class, 'create'])->name('create');
|
||||
Route::post('/', [PostController::class, 'store'])->name('store');
|
||||
@@ -158,7 +175,7 @@
|
||||
Route::post('/', [PostController::class, 'uploadFiles'])->name('upload');
|
||||
Route::delete('/{fileId}', [PostController::class, 'deleteFile'])->name('delete');
|
||||
});
|
||||
});
|
||||
})->where('boardCode', '[a-zA-Z][a-zA-Z0-9_-]*');
|
||||
});
|
||||
|
||||
// 역할 권한 관리 (Blade 화면만)
|
||||
|
||||
Reference in New Issue
Block a user