/**
  * create
  *
  * @param Request                $request         request
  * @param Validator              $validator       validator
  * @param BoardPermissionHandler $boardPermission board permission handler
  * @param IdentifyManager        $identifyManager identify manager
  * @return mixed
  */
 public function store(Request $request, Validator $validator, BoardPermissionHandler $boardPermission, IdentifyManager $identifyManager)
 {
     if (Gate::denies(BoardPermissionHandler::ACTION_CREATE, new Instance($boardPermission->name($this->instanceId)))) {
         throw new AccessDeniedHttpException();
     }
     $this->checkCaptcha();
     $user = Auth::user();
     $this->validate($request, $validator->getCreateRule($user, $this->config));
     $inputs = $request->all();
     $inputs['instanceId'] = $this->instanceId;
     $inputs['title'] = htmlspecialchars($request->originAll()['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
     $inputs['content'] = purify($request->originAll()['content']);
     if ($request->get('status') == Board::STATUS_NOTICE && $this->isManager === false) {
         throw new HaveNoWritePermissionHttpException(['name' => xe_trans('xe::notice')]);
     }
     // 암호 설정
     if (empty($inputs['certifyKey']) === false) {
         $inputs['certifyKey'] = $identifyManager->hash($inputs['certifyKey']);
     }
     /** @var \Xpressengine\Editor\AbstractEditor $editor */
     $editor = XeEditor::get($this->instanceId);
     $inputs['format'] = $editor->htmlable() ? Board::FORMAT_HTML : Board::FORMAT_NONE;
     // set file, tag
     $inputs['_files'] = array_get($inputs, $editor->getFileInputName(), []);
     $inputs['_hashTags'] = array_get($inputs, $editor->getTagInputName(), []);
     $board = $this->handler->add($inputs, $user, $this->config);
     return XePresenter::redirect()->to($this->urlHandler->getShow($board, $request->query->all()))->setData(['item' => $board]);
 }
 /**
  * 글 등록 post
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store()
 {
     if ($this->permissionHandler->hasCreate($this->boardId) === false) {
         throw new AccessDeniedHttpException();
     }
     /** @var \Xpressengine\Http\Request $request */
     $request = app('request');
     $user = Auth::user();
     // get rules
     /** @var BoardValidator $validator */
     $validator = app('xe.board.validator');
     $rules = $validator->getCreateRule($user, $this->config);
     $this->validate($request, $rules);
     $inputs = $request->all();
     // replace purifying content to origin content value
     $inputs['content'] = $request->originAll()['content'];
     // make document entity
     $doc = new DocumentEntity($this->handler->documentFilter($inputs));
     $doc->id = (new Keygen())->generate();
     $doc->instanceId = $this->boardId;
     // 공지
     $doc->notice(false);
     if ($request->get('status') == 'notice' && $this->isManager) {
         $doc->notice(true);
     }
     // make board item entity
     $item = $this->handler->makeItem($doc, $request, $user);
     // 암호 설정
     /** @var \Xpressengine\Plugins\Board\IdentifyManager $identifyManager */
     $identifyManager = app('xe.board.identify');
     if ($doc->certifyKey != null) {
         $doc->certifyKey = $identifyManager->hash($doc->certifyKey);
     }
     $item->setDocument($doc);
     XeDB::beginTransaction();
     // document insert
     $this->handler->add($item, $this->config);
     // 태그 등록
     /** @var \Xpressengine\Tag\TagHandler $tag */
     $tag = app('xe.tag');
     $hashTags = array_unique($request->get('_hashTags', []));
     $tag->set($this->boardId, $doc->id, $hashTags);
     XeDB::commit();
     // 답글인 경우 부모글이 있는 곳으로 이동한다.(최대한..)
     if (Input::get('parentId') != '') {
         return Redirect::to($this->urlHandler->get('index', $this->urlHandler->queryStringToArray(Input::get('queryString'))));
     } else {
         return Redirect::to($this->urlHandler->get('index'));
     }
 }