尝试获取用户列表的分页(工作正常),但在我的过滤器页面(http://wasamar.dev/admin@users@filter?filter=new)上,它给了我这个错误,
ErrorException in Macroable.php line 81:
Method lastPage does not exist. (View: C:\laragon\www\wasamar\resources\views\pagination\limit_links.blade.php) (View: C:\laragon\www\wasamar\resources\views\pagination\limit_links.blade.php)
这是分页器渲染
@include('pagination.limit_links', ['paginator' => $newestUsers])
CUSTOM PAGINATION VIEW
<!--
https://stackoverflow.com/questions/28240777/custom-pagination-view-in-laravel-5
Author: Mantas D
-->
<?php
// config
$link_limit = 7; // maximum number of links (a little bit inaccurate, but will be ok for now)
?>
@if ($paginator->lastPage() > 1)
<div class="pagination-centered">
<ul class="pagination">
<li class="montserrat-font {{ ($paginator->currentPage() == 1) ? ' unavailable' : '' }}">
<a href="{{ $paginator->url(1) }}">First</a>
</li>
@for ($i = 1; $i <= $paginator->lastPage(); $i++)
<?php
$half_total_links = floor($link_limit / 2);
$from = $paginator->currentPage() - $half_total_links;
$to = $paginator->currentPage() + $half_total_links;
if ($paginator->currentPage() < $half_total_links) {
$to += $half_total_links - $paginator->currentPage();
}
if ($paginator->lastPage() - $paginator->currentPage() < $half_total_links) {
$from -= $half_total_links - ($paginator->lastPage() - $paginator->currentPage()) - 1;
}
?>
@if ($from < $i && $i < $to)
<li class="montserrat-font {{ ($paginator->currentPage() == $i) ? ' current' : '' }}">
<a href="{{ $paginator->url($i) }}">{{ $i }}</a>
</li>
@endif
@endfor
<li class="montserrat-font {{ ($paginator->currentPage() == $paginator->lastPage()) ? ' unavailable' : '' }}">
<a href="{{ $paginator->url($paginator->lastPage()) }}">Last</a>
</li>
</ul>
</div>
@endif
基于此(Reference作者:Mantas D)然后我尝试了这个
{{ $newestUsers->links() }}
我也遇到了这个错误。
ErrorException in Macroable.php line 81:
Method links does not exist. (View: C:\laragon\www\wasamar\resources\views\main_app\admin\users@filter.blade.php)
那我做错了什么?
答案 0 :(得分:0)
对此的修复很简单:我忘了将paginate(30)
方法添加到Users模型中。添加它将解决问题。