/** * Get the user results, ready to be serialized and assigned to the * document response. * * @param JsonApiRequest $request * @param Document $document * @return \Illuminate\Database\Eloquent\Collection */ protected function data(JsonApiRequest $request, Document $document) { $criteria = new SearchCriteria($request->actor, $request->get('filter.q'), $request->sort); $results = $this->searcher->search($criteria, $request->limit, $request->offset, $request->include); $this->addPaginationLinks($document, $request, $this->url->toRoute('users.index'), $results->areMoreResults()); return $results->getResults(); }
/** * Get the discussion results, ready to be serialized and assigned to the * document response. * * @param JsonApiRequest $request * @param Document $document * @return \Illuminate\Database\Eloquent\Collection */ protected function data(JsonApiRequest $request, Document $document) { $criteria = new SearchCriteria($request->actor, $request->get('filter.q'), $request->sort); $load = array_merge($request->include, ['state']); $results = $this->searcher->search($criteria, $request->limit, $request->offset, $load); // TODO: add query params (filter, sort, include) to the pagination URLs $this->addPaginationLinks($document, $request, $request->http ? $this->url->toRoute('discussions.index') : '', $results->areMoreResults()); return $results->getResults(); }
/** * {@inheritdoc} */ protected function data(ServerRequestInterface $request, Document $document) { $actor = $request->getAttribute('actor'); $query = array_get($this->extractFilter($request), 'q'); $sort = $this->extractSort($request); $criteria = new SearchCriteria($actor, $query, $sort); $limit = $this->extractLimit($request); $offset = $this->extractOffset($request); $results = $this->searcher->search($criteria, $limit, $offset); $document->addPaginationLinks($this->url->toRoute('pages.index'), $request->getQueryParams(), $offset, $limit, $results->areMoreResults() ? null : 0); return $results->getResults(); }