raf*_*tio 5 php laravel laravel-pagination
我想创建一个返回为 json 的分页,但出现如下错误
Macroable.php 第 74 行中的 ErrorException:方法链接不存在。
这是我的控制器代码
 public function getcustomer($id){
    $customer = Customer::find($id)->paginate(5);
    return response()->json([$customer], 200);
}
这里是我的刀片代码
{{$customer->links('vendor.pagination.pagination')}}
如何使用 json response() 创建分页?
Laravel 分页器结果类实现了
Illuminate\Contracts\Support\JsonableInterface 契约并公开了该toJson方法,因此可以非常轻松地将分页结果转换为 JSON。
https://laravel.com/docs/5.3/pagination#converting-results-to-json
如果您想建立链接,您应该手动进行。或者您应该照常返回分页,并使用render()方法来构建链接并创建分页对象的副本,以将其转换为 JSON toJson()。
| 归档时间: | 
 | 
| 查看次数: | 22157 次 | 
| 最近记录: |