/**
  * get voted user list
  *
  * @param Request $request
  * @param $menuUrl
  * @param $option
  * @param $id
  * @return mixed
  */
 public function votedUserList(Request $request, $menuUrl, $option, $id)
 {
     $startId = $request->get('startId');
     $limit = $request->get('limit', 10);
     $item = $this->handler->getModel($this->config)->find($id);
     $this->handler->setModelConfig($item, $this->config);
     $counter = $this->handler->getVoteCounter();
     $logModel = $counter->newModel();
     $query = $logModel->where('counterName', $counter->getName())->where('targetId', $id)->where('counterOption', $option);
     if ($startId != null) {
         $query->where('id', '<', $startId);
     }
     $logs = $query->orderBy('id', 'desc')->take($limit)->get();
     $list = [];
     foreach ($logs as $log) {
         /** @var User $user */
         $user = $log->user;
         $profilePage = '#';
         if ($user->getId() != '') {
             $profilePage = route('member.profile', ['member' => $user->getId()]);
         }
         $list[] = ['id' => $user->getId(), 'displayName' => $user->getDisplayName(), 'profileImage' => $user->getProfileImage(), 'createdAt' => (string) $log->createdAt, 'profilePage' => $profilePage];
     }
     $nextStartId = 0;
     if (count($logs) == $limit) {
         $nextStartId = $logs->last()->id;
     }
     return XePresenter::makeApi(['item' => $item, 'list' => $list, 'nextStartId' => $nextStartId]);
 }
 /**
  * set current page
  *
  * @param Request       $request       request
  * @param Handler       $handler       handler
  * @param ConfigHandler $configHandler config handler
  * @param BoardSlug     $slug          slug model
  * @return void
  */
 protected function setCurrentPage(Request $request, Handler $handler, ConfigHandler $configHandler, BoardSlug $slug)
 {
     $instanceId = $slug->instanceId;
     // 이 slug 가 포함된 페이지 출력
     $config = $configHandler->get($instanceId);
     $query = $handler->getModel($config)->where('instanceId', $instanceId)->visible();
     $orderType = $request->get('orderType', '');
     if ($orderType === '' && $config->get('orderType') != null) {
         $orderType = $config->get('orderType', '');
     }
     if ($orderType == '') {
         $query->where('head', '>=', $slug->board->head);
     } elseif ($orderType == 'assentCount') {
         $query->where('assentCount', '>', $slug->board->assentCount)->orWhere(function ($query) use($slug) {
             $query->where('assentCount', '=', $slug->board->assentCount);
             $query->where('head', '>=', $slug->board->head);
         });
     } elseif ($orderType == 'recentlyCreated') {
         $query->where(Board::CREATED_AT, '>', $slug->board->{Board::CREATED_AT})->orWhere(function ($query) use($slug) {
             $query->where(Board::CREATED_AT, '=', $slug->board->{Board::CREATED_AT});
             $query->where('head', '>=', $slug->board->head);
         });
     } elseif ($orderType == 'recentlyUpdated') {
         $query->where(Board::UPDATED_AT, '>', $slug->board->{Board::UPDATED_AT})->orWhere(function ($query) use($slug) {
             $query->where(Board::UPDATED_AT, '=', $slug->board->{Board::UPDATED_AT});
             $query->where('head', '>=', $slug->board->head);
         });
     }
     Event::fire('xe.plugin.board.archive', [$query, $slug->board]);
     $count = $query->count() ?: 1;
     $page = (int) ($count / $config->get('perPage'));
     if ($count % $config->get('perPage') != 0) {
         ++$page;
     }
     $request->query->set('page', $page);
 }