我正在Laravel 5中使用Illuminate'Pagination'Paginator
和Illuminate'Pagination'LengthAwarePaginator
手动创建自己的自定义分页。直到我在控制器上添加了一个构造函数,它才工作得很好。即使只是一个空白的构造函数也会返回一个错误。
use App'Controllers'CoreController;
use Illuminate'Pagination'Paginator;
use Illuminate'Pagination'LengthAwarePaginator;
class CodeTables extends CoreController {
public function __construct()
{
// nothing here, just blank
}
public function index()
{
$pagination = new LengthAwarePaginator($contents, $totalRows, $rowsPerPage, Paginator::resolveCurrentPage(), array('path' => Paginator::resolveCurrentPath()));
}
}
当我有那个构造函数时,它会给我一个错误:ErrorException in LengthAwarePaginator.php line 47: Division by zero
但是移除构造函数方法非常好。
如果您确信在CodeTables
类中没有定义构造函数时一切正常,那么您应该在构造函数中调用父构造函数:
public function __construct()
{
// nothing here, just blank
parent::__construct();
}