【发布时间】:2015-07-27 13:35:22
【问题描述】:
我想在一页上显示所有博客,但想对它们进行分页。分页有效,但链接似乎没有出现在视图中。它一直向我显示此错误:
调用未定义的方法 Illuminate\Database\Eloquent\Collection::links()
代码如下:
public static function all()
{
return \ExpoPost::with('attachment')->published()->type('post')->orderBy('post_date')->paginate(5);
}
在视图中我正在尝试做这样的事情
@foreach($posts as $post)
<p>{{$post->post_title}}</p>
@endforeach
<p>{{$posts->links()}}</p>
有人可以帮帮我吗?
【问题讨论】:
-
看起来不错。如果你删除
{{$posts->links()}}
你的@foreach 会显示吗? -
是的,我的@foreach 工作正常
标签: php laravel-4 pagination