Laravel 5中带有附加链接的自定义分页视图

fnx2tebb  于 2023-06-24  发布在  其他
关注(0)|答案(2)|浏览(111)

如图所示:Custom pagination view in Laravel 5

@include('pagination.default', ['paginator' => $users])

替换原来的:

$users->render();

但如何取代它呢?

$users->appends(['sortBy' => $sort, 'order' => $order])->render()


@if ($paginator->lastPage() > 1)
<ul class="pagination">
    <li class="{{ ($paginator->currentPage() == 1) ? ' disabled' : '' }}">
        <a href="{{ $paginator->url(1) }}">Previous</a>
    </li>
    @for ($i = 1; $i <= $paginator->lastPage(); $i++)
        <li class="{{ ($paginator->currentPage() == $i) ? ' active' : '' }}">
            <a href="{{ $paginator->url($i) }}">{{ $i }}</a>
        </li>
    @endfor
    <li class="{{ ($paginator->currentPage() == $paginator->lastPage()) ? ' disabled' : '' }}">
        <a href="{{ $paginator->url($paginator->currentPage()+1) }}" >Next</a>
    </li>
</ul>
@endif
enyaitl3

enyaitl31#

杜普

@include('pagination.default', [
    'paginator' => $users->appends([
        'sortBy' => $sort,
        'order' => $order,
    ])
])
pn9klfpd

pn9klfpd2#

最佳做法是:

$users->appends(Request::query())->links('Your custom pagination view name');

如果您希望使用自定义参数而不是all请求,则只需替换

'Request::query()' to ['sortBy' => $sort, 'order' => $order].

相关问题