0

I'm using this code for custom pagination with dynamic links.

@if ($paginator->hasPages())
<div class="intro-y col-span-12 flex flex-wrap sm:flex-row sm:flex-no-wrap items-center">
    <ul class="pagination">
        @if ($paginator->onFirstPage())
        <li>
            <a class="pagination__link cursor-not-allowed" href="javascript:void(0)">
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-left w-4 h-4">
                    <polyline points="15 18 9 12 15 6"></polyline>
                </svg>
                <!-- <i class="w-4 h-4" data-feather="chevron-left"></i> -->
            </a>
        </li>
        @else
        <li>
            <a class="pagination__link" href="javascript:void(0)" onclick="paginateRedirect(this,'{{ $paginator->previousPageUrl() }}')">
                <!-- <i class="w-4 h-4" data-feather="chevron-left"></i> -->
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-left w-4 h-4">
                    <polyline points="15 18 9 12 15 6"></polyline>
                </svg>
            </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>
            <a class="pagination__link pagination__link--active" href="javascript:void(0)" onclick="paginateRedirect(this,'')">{{ $page }}</a>
        </li>
        @else
        <li><a class="pagination__link" href="javascript:void(0)" onclick="paginateRedirect(this,'{{ $url }}')">{{ $page }}</a></li>
        @endif
        @endforeach
        @endif
        @endforeach

        @if ($paginator->hasMorePages())

        <li>
            <a class="pagination__link" href="javascript:void(0)" onclick="paginateRedirect(this,'{{ $paginator->nextPageUrl() }}')">
                <!-- <i class="w-4 h-4" data-feather="chevron-right"></i> -->
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right w-4 h-4"><polyline points="9 18 15 12 9 6"></polyline></svg>
            </a>
        </li>
        @else
        <li>
            <a class="pagination__link hidden" href="javascript:void(0)">
                <!-- <i class="w-4 h-4" data-feather="chevron-right"></i> -->
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right w-4 h-4"><polyline points="9 18 15 12 9 6"></polyline></svg>
            </a>
        </li>
        @endif
    </ul>
</div>
@endif

when I execute this code, it looks fine but pagination links are not working properly.

I need different pagination style with different pages, how I can use above code for all pages with different styling.

0 Answers0