Laravel 6 一页多页

Laravel 6 multiple pagination in one page

我想在一页中创建多个分页,info 分页效果很好。但 berita 分页链接到 info,并且始终显示 info 页而不是 berita 页。

控制器

$infos = Info::paginate(4, ['*'], 'info');
$beritas = Berita::paginate(4, ['*'], 'berita');

查看

{{$infos->appends(['info' => $infos->currentPage()])->links()}}
{{$beritas->appends(['berita' => $beritas->currentPage()])->links()}}

EDITED

信息

<ul class="pagination">
<li class="page-item disabled" aria-disabled="true" aria-label="« Sebelumnya">
   <span class="page-link" aria-hidden="true">‹</span>
</li>
<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>
<li class="page-item"><a class="page-link" href="http://127.0.0.1:8000?info=2">2</a></li>
<li class="page-item">
   <a class="page-link" href="http://127.0.0.1:8000?info=2" rel="next" aria-label="Berikutnya »">›</a>
</li>
</ul>

贝里塔

<ul class="pagination">
<li class="page-item">
   <a class="page-link" href="http://127.0.0.1:8000?berita=1" rel="prev" aria-label="« Sebelumnya">‹</a>
</li>
<li class="page-item"><a class="page-link" href="http://127.0.0.1:8000?berita=1">1</a></li>
<li class="page-item active" aria-current="page"><span class="page-link">2</span></li>
<li class="page-item disabled" aria-disabled="true" aria-label="Berikutnya »">
   <span class="page-link" aria-hidden="true">›</span>
</li>
</ul>

EDITED

现在可以使用了,但它总是在 berita 分页中显示一个 info data

只要您跟踪相反集合的页面值,这应该是可能的:

{{$infos->appends(['info' => $infos->currentPage(), 'berita' => $beritas->currentPage()])->links()}}

{{$beritas->appends(['berita' => $beritas->currentPage(), 'info' => $infos->currentPage()])->links()}}

如果我有时间,我会稍后尝试测试这个理论。