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

时间:2015-06-03 17:06:31

标签: laravel pagination laravel-5

如下所示:Custom pagination view in Laravel 5

 $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

取代原来的:

{{1}}

但如何更换呢?

{{1}}

2 个答案:

答案 0 :(得分:2)

Durp。

@include('pagination.default',['paginator'=&gt; $ users-&gt;追加(['sortBy'=&gt; $ sort,'order'=&gt; $ order])])

答案 1 :(得分:0)

最佳做法是:

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

如果您想使用自定义参数而不是全部请求,则只需替换

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