route('code'); // 게시판 코드 확인 if (!$code) { 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('더 이상 사용하지 않는 게시판입니다.'); } $boardMeta = $boardService->meta($board->id); // 이미지 첨부 권한 확인 $response = Gate::inspect('uploader', ['App\Model\Post', $boardMeta]); if($response->denied()) { throw new Exception($response->message()); } }catch(Exception $e) { return alert($e->getMessage(), null, false); } return $next($request); } }