paginate.blade.php 2.19 KB
@if ($paginator->hasPages())
<div class="pagination">
    @if ($paginator->onFirstPage())
        <a href="{{ $paginator->previousPageUrl() }}" class="pagination__nav pagination__nav_prev">
            <svg>
                <use xlink:href="{{ asset('images/sprite.svg#arrow-bold') }}"></use>
            </svg>
        </a>
    @else
    <a href="{{ $paginator->previousPageUrl() }}" class="pagination__nav pagination__nav_prev">
        <svg>
            <use xlink:href="{{ asset('images/sprite.svg#arrow-bold') }}"></use>
        </svg>
    </a>
    @endif

    @foreach ($elements as $element)
            @if (is_string($element))
                <span>{{ $element }}</span>
            @endif

            @if (is_array($element))
                @php $count_element = count($element);
                     $i = 0;
                @endphp
                @foreach ($element as $page => $url)
                    @if ($page == $paginator->currentPage())
                        <span class="pagination__item active">{{ $page }}</span>
                    @else
                        @if (($i == $count_element - 1) && ($count_element > 5))
                            <span class="pagination__dots">
                                <svg>
                                    <use xlink:href="{{ asset('images/sprite.svg#dots') }}"></use>
                                </svg>
                            </span>
                        @endif

                        <a href="{{ $url }}" class="pagination__item">{{ $page }}</a>
                    @endif
                    @php $i++; @endphp
                @endforeach
            @endif
    @endforeach

    @if ($paginator->hasMorePages())
            <a href="{{ $paginator->nextPageUrl() }}" class="pagination__nav pagination__nav_next">
                <svg>
                    <use xlink:href="{{ asset('images/sprite.svg#arrow-bold') }}"></use>
                </svg>
            </a>
    @else
            <a href="{{ $paginator->nextPageUrl() }}" class="pagination__nav pagination__nav_next">
                <svg>
                    <use xlink:href="{{ asset('images/sprite.svg#arrow-bold') }}"></use>
                </svg>
            </a>
    @endif
</div>
@endif