@if ($paginator->hasPages())
    <ul class="pagination pagination-rounded justify-content-end mt-4">
        {{-- Previous Page Link --}}
        @if ($paginator->onFirstPage())
            <li class="page-item disabled"><a href="javascript:;" wire:click="previousPage" class="page-link">Prev</a></li>
        @else
        <li class="page-item"><a href="javascript:;" wire:click="previousPage" rel="prev" class="page-link">Prev</a></li>
        @endif

        {{-- Pagination Element Here --}}
        @foreach ($elements as $element)
            {{-- Make dots here --}}
            @if (is_string($element))
                <li class="page-item disabled"><a class="page-link"><span>{{ $element }}</span></a></li>
            @endif

            {{-- Links array Here --}}
            @if (is_array($element))
                @foreach ($element as $page=>$url)
                    @if ($paginator->currentPage() > 3 && $page === 2)
                        <li class="page-item disabled"><span class="page-link">...</span></li>
                    @endif
                    @if ($page == $paginator->currentPage())
                        <li class="page-item active" aria-current="page"><a href="javascript:;" wire:click="gotoPage({{$page}})" class="page-link bg-pagination"><span>{{ $page }}</span></a></li>
                    @elseif ($page === $paginator->currentPage() + 1 || 
                        $page === $paginator->currentPage() - 1 || 
                        $page === $paginator->lastPage() || 
                        $page === 1
                    )
                        <li class="page-item"><button type="button" class="page-link" wire:click="gotoPage({{ $page }}, '{{ $paginator->getPageName() }}')">{{ $page }}</button></li>
                    @endif
                    @if ($paginator->currentPage() < $paginator->lastPage() - 2 && $page === $paginator->lastPage() - 1)
                        <li class="page-item disabled"><span class="page-link">...</span></li>
                    @endif
                @endforeach
            @endif
        @endforeach

        {{-- Next Page Link --}}
        @if ($paginator->hasMorePages())
            <li class="page-item"><a href="javascript:;" wire:click="nextPage" class="page-link">Next</a></li>
        @else
          <li class="page-item disabled"><a href="javascript:;" class="page-link">Next</a></li>
        @endif
    </ul>
@endif