Call to undefined method IlluminatePaginationPaginator::make()?(调用未定义的方法 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()
Call to undefined method IlluminatePaginationPaginator::make()
当我将 use IlluminateSupportFacadesPaginator;
替换为 use IlluminatePaginationPaginator;
时,它会抛出:
And when I replace use IlluminateSupportFacadesPaginator;
with use IlluminatePaginationPaginator;
, then it throws:
找不到类 'IlluminateSupportFacadesPaginator'
Class 'IlluminateSupportFacadesPaginator' not found
知道如何修复它吗?
推荐答案
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()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:调用未定义的方法 IlluminatePaginationPaginator::make()?
基础教程推荐
- 使用 PDO 转义列名 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01