哈士奇WWW
我唯一能做的就是使用这个宏对集合进行分页,所以将此代码添加到我的 AppServiceProvider 中use Illuminate\Pagination\LengthAwarePaginator;use Illuminate\Support\Collection;Collection::macro('paginate', function ($perPage, $total = null, $page = null, $pageName = 'page') { $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName); return new LengthAwarePaginator($this->forPage($page, $perPage), $total ?: $this->count(), $perPage, $page, [ 'path' => LengthAwarePaginator::resolveCurrentPath(), 'pageName' => $pageName, ]);});然后我将对集合进行分页$logbooks = $this->log_book->orderBy('created_at','desc')->limit(1000)->get();$logbooks->paginate(100);