$agentInfo = $agentInfo->union($agentInfo2)->orderBy('AllScore','desc')->get(); $page = $request->get('page',1); $collection = new Collection($agentInfo); $perPage = 20; $currentData = $collection->slice(($page-1)*$perPage,$perPage)->all(); $result = new LengthAwarePaginator($currentData,count($collection),$perPage); $path = url()->current(); $result->setPath($path);