/** * 즐겨찾기 등록, 삭제 * * @param string $menuUrl first segment * @param string $id document id * @return \Xpressengine\Presenter\RendererInterface */ public function favorite($menuUrl, $id) { if (Auth::check() === false) { throw new AccessDeniedHttpException(); } $board = $this->handler->getModel($this->config)->find($id); $userId = Auth::user()->getId(); $favorite = false; if ($this->handler->hasFavorite($board->id, $userId) === false) { $this->handler->addFavorite($board->id, $userId); $favorite = true; } else { $this->handler->removeFavorite($board->id, $userId); } return XePresenter::makeApi(['favorite' => $favorite]); }