php - 在 laravel 外使用照明/分页
问题描述
我尝试laravel pagination
在我的自定义 CMS中使用
工作illuminate/pagination
,但不正确
此代码用于我的控制器工作
$cats= Category::paginate(2);
但是当我想在刀片引擎中调用这段代码中的分页链接时
{{$cats->links()}}
or
{!! $cats->links() !!}
or
{{$cats->render()}}
我收到这个错误
call_user_func() expects parameter 1 to be a valid callback, no array or string given (View: C:\xampp\htdocs\gitrepo\mvcframwork\resources\view\admin\products\category.blade.php)
git 项目网址 https://github.com/mohammadZx/mvcframwork/tree/log
你可以在 github 的 log 分支上检查项目
我认为这个问题属于laravel pagination service provider
但我仍然不知道如何注册 laravel 提供者或解决这个问题
解决方案
你必须注册PaginationSerivceProvider
。遵循方法并执行所需PaginationSerivceProvider
的操作regsiter
或者
转到LengthAwarePaginator.php
文件并为具有包含属性的此方法重构刀片或视图处理程序,您应该知道下面的方法具有所有分页系统,只需要在视图处理程序中要求
public function render($view = null, $data = [])
{
return static::viewFactory()->make($view ?: static::$defaultView,
array_merge($data, [
'paginator' => $this,
'elements' => $this->elements(),
]));
}
推荐阅读
- google-cloud-functions - 为什么一次可调用的客户端调用会调用两次 onCall firebase 函数?
- python - 如何在 matplotlib.axes.Axes.stem 图中显示时间线?
- python - 使用简单的 python tcp 脚本连接同一主机上的两个 Docker 容器,但出现连接被拒绝错误
- arduino - 通过带有串口包的 NodeJS 应用程序硬重置 ESP32
- vue.js - 渲染按钮时 V-IF 无反应
- vhdl - VHDL 组件可以完美地分开工作;在上层实体中连接它们时遇到问题
- angular - Angular 使用 Resolver 为几个字段预填充数据,resolver 将返回一个 Observable 内部订阅者
- image - 如何从 Google 云端硬盘创建图像文件并将其插入到 Google Apps 脚本 UrlFetchApp.fetch 对外部 API 的调用中?
- javascript - 可以为视频添加新来源吗?
- c++ - C++:如何遍历向量中的整数元素