IlluminatePaginationPaginator

IlluminatePaginationPaginator

本文介绍了调用未定义的方法 IlluminatePaginationPaginator::make()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

use IlluminateSupportCollection;
use IlluminateSupportFacadesInput;
use IlluminatePaginationPaginator;
.
.
$collection = new Collection($guarantee_ticket);
// Paginate
$perPage = 3;
$currentPage = Input::get('page') - 1; // url.com/test?page=2
$pagedData = $collection->slice($currentPage * $perPage, $perPage)->all();
$pagination= Paginator::make($pagedData, count($collection), $perPage);

它抛出:

调用未定义的方法IlluminatePaginationPaginator::make()

当我将 use IlluminateSupportFacadesPaginator; 替换为 use IlluminatePaginationPaginator; 时,它会抛出:

And when I replace use IlluminateSupportFacadesPaginator; with use IlluminatePaginationPaginator;, then it throws:

找不到类 'IlluminateSupportFacadesPaginator'

知道如何修复它吗?

推荐答案

Class IlluminatePaginationPaginator 没有 make() 方法.

你用构造函数实例化它.另外,第二个参数是 perPage,第三个参数是 currentPage:

You instantiate it with the constructor. Also, 2nd parameter is perPage, 3rd is currentPage:

$pagination = new Paginator($pagedData, $perPage);

文档 绝对令人困惑,如果不是明显错误的话.它显示了工厂,但查看源链接到 Laravel 4.2 类,这在 Laravel 5.6 中不存在.

Documentation is definitely confusing, if not plainly wrong. It shows the Factory, but the view source links to Laravel 4.2 class, that is nonexistant in Laravel 5.6.

这篇关于调用未定义的方法 IlluminatePaginationPaginator::make()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-07 17:11