【发布时间】:2020-01-30 10:18:52
【问题描述】:
我的 laravel 中有一个包含多个类别的博客模块。在其他类别中分页工作得很好,但使用此类别方法 links() 总是显示第一页。这是我的代码:
$page = Categoriepage::where('identifiant', 'orientation')->first();
$idArticle = Articleliaison::select(array('idArticle'))->where('idPage',$page->id)->pluck('idArticle');
$articles = Article::whereIn('id',$idArticle)->where('status','enable')->orderby('created_at','desc')->get()->take(6);
$links = Article::whereIn('id',$idArticle)->where('status','enable')->orderby('created_at','desc')->paginate(6);
return View::make('pages.orientation')->with('articles',$articles)->with('links',$links);
在我看来:
<?php $i = 1 ?>
<div class="masonry ">
@foreach($articles as $article)
@include('components.article-or')
<?php $i++ ?>
@endforeach()
</div>
<div class="text-center" style="margin-top: 5%">
{{ $links->links() }}
</div>
【问题讨论】:
-
{{ $links->links() }}这应该是{{ $articles->links() }}