public function index(APIRequest $request) { $limit = $this->getItemsPerPage($request); $locations = Location::query(); $locations = $this->processDateFilters($request, $locations); $this->processOrdering($request, $locations); $locations = $locations->paginate($limit); $resource = new Collection($locations->items(), new LocationTransformer(), 'location'); $resource->setPaginator(new IlluminatePaginatorAdapter($locations)); return $this->fractal->createData($resource)->toArray(); }