调用未定义的方法Illuminate \ Pagination \ Paginator :: make()? [英] Call to undefined method Illuminate\Pagination\Paginator::make()?
问题描述
这是我的代码:
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Input;
use Illuminate\Pagination\Paginator;
.
.
$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);
它抛出:
调用未定义的方法Illuminate \ Pagination \ Paginator :: make()
Call to undefined method Illuminate\Pagination\Paginator::make()
当我用use Illuminate\Pagination\Paginator;
替换use Illuminate\Support\Facades\Paginator;
时,它会抛出:
And when I replace use Illuminate\Support\Facades\Paginator;
with use Illuminate\Pagination\Paginator;
, then it throws:
找不到"Illuminate \ Support \ Facades \ Paginator"类
Class 'Illuminate\Support\Facades\Paginator' not found
任何想法我该如何解决?
Any idea how can I fix it?
推荐答案
Class Illuminate\Pagination\Paginator
没有make()
方法.
Class Illuminate\Pagination\Paginator
doesn't have a make()
method.
您可以使用构造函数实例化它.另外,第2个参数是perPage
,第3个参数是currentPage
:
You instantiate it with the constructor. Also, 2nd parameter is perPage
, 3rd is currentPage
:
$pagination = new Paginator($pagedData, $perPage);
文档确实令人困惑,即使不是很明显的错误.它显示了Factory,但是视图源链接到Laravel 5.6
类,而该类在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
.
这篇关于调用未定义的方法Illuminate \ Pagination \ Paginator :: make()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!