在 Laravel 中调用数组上的成员函数 links()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40677482/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Call to a member function links() on array in laravel
提问by kunal
I dont know what happens. I am using pagination but it gives me error like:- Call to a member function links() on array
我不知道会发生什么。我正在使用分页,但它给了我类似的错误:- 调用数组上的成员函数 links()
Here is My code Function:-
这是我的代码功能:-
enter code here
use Illuminate\Pagination\LengthAwarePaginator;
public function index(){
$data = DB::table('tasks')->paginate(1);
$data= json_decode(json_encode($data),true);
return view('index',['data'=>$data]);
}
And i used in blade file in end where foreach finish:-
我在刀片文件中最后使用了 foreach 完成:-
enter code here
{{ $data->links() }}
回答by szebasztian
You dont have to decode the json. Read the docs: https://laravel.com/docs/5.3/pagination
您不必解码 json。阅读文档:https: //laravel.com/docs/5.3/pagination
You should do this:
你应该做这个:
public function index(){
$data = DB::table('tasks')->paginate(1);
return view('index',['data'=>$data]);
}