22
33namespace Laravel \Scout ;
44
5+ use Illuminate \Container \Container ;
56use Illuminate \Pagination \LengthAwarePaginator ;
67use Illuminate \Pagination \Paginator ;
78use Illuminate \Support \Traits \Macroable ;
@@ -270,10 +271,16 @@ public function paginate($perPage = null, $pageName = 'page', $page = null)
270271 $ this , $ rawResults = $ engine ->paginate ($ this , $ perPage , $ page ), $ this ->model
271272 )->all ());
272273
273- $ paginator = (new LengthAwarePaginator ($ results , $ engine ->getTotalCount ($ rawResults ), $ perPage , $ page , [
274- 'path ' => Paginator::resolveCurrentPath (),
275- 'pageName ' => $ pageName ,
276- ]));
274+ $ paginator = Container::getInstance ()->makeWith (LengthAwarePaginator::class, [
275+ 'items ' => $ results ,
276+ 'total ' => $ engine ->getTotalCount ($ rawResults ),
277+ 'perPage ' => $ perPage ,
278+ 'currentPage ' => $ page ,
279+ 'options ' => [
280+ 'path ' => Paginator::resolveCurrentPath (),
281+ 'pageName ' => $ pageName ,
282+ ],
283+ ]);
277284
278285 return $ paginator ->appends ('query ' , $ this ->query );
279286 }
@@ -296,10 +303,16 @@ public function paginateRaw($perPage = null, $pageName = 'page', $page = null)
296303
297304 $ results = $ engine ->paginate ($ this , $ perPage , $ page );
298305
299- $ paginator = (new LengthAwarePaginator ($ results , $ engine ->getTotalCount ($ results ), $ perPage , $ page , [
300- 'path ' => Paginator::resolveCurrentPath (),
301- 'pageName ' => $ pageName ,
302- ]));
306+ $ paginator = Container::getInstance ()->makeWith (LengthAwarePaginator::class, [
307+ 'items ' => $ results ,
308+ 'total ' => $ engine ->getTotalCount ($ results ),
309+ 'perPage ' => $ perPage ,
310+ 'currentPage ' => $ page ,
311+ 'options ' => [
312+ 'path ' => Paginator::resolveCurrentPath (),
313+ 'pageName ' => $ pageName ,
314+ ],
315+ ]);
303316
304317 return $ paginator ->appends ('query ' , $ this ->query );
305318 }
0 commit comments