php – Laravel 5.2 – 方法链接不存在
发布时间:2020-12-14 19:35:58 所属栏目:大数据 来源:网络整理
导读:我将我的数组$帖子传递给我的视图,我尝试使用分页,但我有错误: Method links does not exist. (View: C:xampphtdocsappresourcesviewssearch.blade.php) CONTROLLER $posts = Post::where('visible',1)-where('expire_date','',$current)-where('dele
我将我的数组$帖子传递给我的视图,我尝试使用分页,但我有错误:
CONTROLLER $posts = Post::where('visible',1) ->where('expire_date','>',$current)->where('delete',0); $posts->paginate(1); $posts = $posts->get(); return view('search',compact('posts')); 视图 <div class="pagination-bar text-center"> {{ $posts->links() }} </div> 解决方法
将您的代码更改为:
$posts = Post::where('visible',1) ->where('expire_date',$current) ->where('delete',0) ->paginate(1); return view('search',compact('posts')); 您的代码不起作用,因为您没有将paginate()结果保存到变量,例如$posts = $posts-> paginate(1);.此外,您不应在paginate()之后使用get()或all(). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |