route('code'); $postID = $request->route('postID'); // 게시판 코드 확인 if (!$code || !$postID) { throw new Exception('잘못된 접근입니다.', 404); } $boardService = new BoardService(); // 게시판 정보 조회 $board = $boardService->find($code); // 게시판 존재 유무 if (!$board->exists) { throw new Exception('존재하지 않는 게시판입니다.'); } // 게시판 사용 여부 if ($board->is_display == 0) { throw new Exception('더 이상 사용하지 않는 게시판입니다.'); } $postService = new PostService(); // 게시글 조회 $post = $postService->postModel->isExists($postID); // 게시글 존재 유무 if (!$post) { throw new Exception('존재하지 않는 게시글입니다.'); } // 게시판 설정 값 $boardMeta = $boardService->meta($board->id); // 보기 권한 확인 $response = Gate::inspect('viewAny', ['App\Models\Comment', $boardMeta]); if($response->denied()) { throw new Exception($response->message()); } $request->merge([ 'board' => $board, 'boardMeta' => $boardMeta ]); }catch(Exception $e) { return response(view(layout('board.comment.error'), [ 'message' => $e->getMessage() ])); } return $next($request); } }