F
F
feniksdv2021-04-02 15:48:55
Laravel
feniksdv, 2021-04-02 15:48:55

How to customize paginator in Laravel?

Hello. I can’t figure out how to make the paginator output me 1 2 3 4 5 ... 11 now it displays me so it 60671322f1a64956870710.pngturns out I want 6 to not be a

controller

$paginator = News::paginate(10);
        return view('news', ['paginator'=>$paginator]);


paginate blade

@if ($paginator->hasPages())

    <ul class="pagination">
        @if ($paginator->onFirstPage())

            <li class="disabled"><span>&laquo;</span></li>

        @else

            <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li>

        @endif
        @foreach ($elements as $element)
            @if (is_string($element))

                <li class="disabled"><span>{{ $element }}</span></li>

            @endif
            @if (is_array($element))
                @foreach ($element as $page => $url)
                    @if ($page == $paginator->currentPage())

                        <li class="active"><span>{{ $page }}</span></li>

                    @else

                        <li><a href="{{ $url }}">{{ $page }}</a></li>

                    @endif
                @endforeach
            @endif
        @endforeach
        @if ($paginator->hasMorePages())

            <li><a href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li>

        @else

            <li class="disabled"><span>&raquo;</span></li>

        @endif
    </ul>
@endif


displaying pagination in the template

{{ $paginator->onEachSide(1)->links('paginate') }}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question