/** * 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]); }
/** * move to copy * * @return \Illuminate\Http\RedirectResponse|Redirect */ public function copy(Request $request) { $documentIds = $request->get('id'); $documentIds = is_array($documentIds) ? $documentIds : [$documentIds]; $instanceId = $request->get('instanceId'); $config = $this->configHandler->get($instanceId); if ($config === null) { throw new NotFoundConfigHttpException(['instanceId' => $instanceId]); } $items = Board::find($documentIds); foreach ($items as $item) { $this->handler->setModelConfig($item, $this->configHandler->get($item->instanceId)); $user = new Guest(); if ($item->userId != '') { $user = User::find($item->userId); } $this->handler->copy($item, $user, $config); } Session::flash('alert', ['type' => 'success', 'message' => xe_trans('xe::processed')]); return $this->presenter->makeApi([]); }