Search code examples
laravelpaginationserver-sidevoyagerlaravel-pagination

Laravel Voyager server-side pagination links not showing


I am developing with Laravel 8.4 ("laravel/framework": "^8.40") and Voyager 1.4 ("tcg/voyager": "^1.4").

I am facing an unusual bug with Laravel Voyager. When I am activating Server-Side pagination for any BREAD, the pagination-links section is breaking as below:

enter image description here

enter image description here

However, they are working when I am turning off Server-Side pagination as below:

enter image description here

enter image description here

I am not getting any error messages on the browser console or elsewhere.

The "<< Previous" and "Next >>" buttons are working as expected though, but there's no styling on them.

I have inspected the HTML of the specific part. The Links are present there, but are not being properly presented in browsers for some reason. The HTML of the section is as below:

<div class="pull-right">
                                <nav role="navigation" aria-label="Pagination Navigation" class="flex items-center justify-between">
        <div class="flex justify-between flex-1 sm:hidden">
                            <a href="http://tabapp.test/admin/departments?sort_order=desc&amp;showSoftDeleted=0&amp;page=1" class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150">
                    « Previous
                </a>
            
                            <a href="http://tabapp.test/admin/departments?sort_order=desc&amp;showSoftDeleted=0&amp;page=3" class="relative inline-flex items-center px-4 py-2 ml-3 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150">
                    Next »
                </a>
                    </div>

        <div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
            <div>
                <p class="text-sm text-gray-700 leading-5">
                    Showing
                    <span class="font-medium">16</span>
                    to
                    <span class="font-medium">30</span>
                    of
                    <span class="font-medium">67</span>
                    results
                </p>
            </div>

            <div>
                <span class="relative z-0 inline-flex shadow-sm rounded-md">
                    
                                            <a href="http://tabapp.test/admin/departments?sort_order=desc&amp;showSoftDeleted=0&amp;page=1" rel="prev" class="relative inline-flex items-center px-2 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-l-md leading-5 hover:text-gray-400 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-500 transition ease-in-out duration-150" aria-label="&amp;laquo; Previous">
                            <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
                                <path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd"></path>
                            </svg>
                        </a>
                    
                    
                                            
                        
                        
                                                                                                                        <a href="http://tabapp.test/admin/departments?sort_order=desc&amp;showSoftDeleted=0&amp;page=1" class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 hover:text-gray-500 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150" aria-label="Go to page 1">
                                        1
                                    </a>
                                                                                                                                <span aria-current="page">
                                        <span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">2</span>
                                    </span>
                                                                                                                                <a href="http://tabapp.test/admin/departments?sort_order=desc&amp;showSoftDeleted=0&amp;page=3" class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 hover:text-gray-500 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150" aria-label="Go to page 3">
                                        3
                                    </a>
                                                                                                                                <a href="http://tabapp.test/admin/departments?sort_order=desc&amp;showSoftDeleted=0&amp;page=4" class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 hover:text-gray-500 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150" aria-label="Go to page 4">
                                        4
                                    </a>
                                                                                                                                <a href="http://tabapp.test/admin/departments?sort_order=desc&amp;showSoftDeleted=0&amp;page=5" class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 hover:text-gray-500 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150" aria-label="Go to page 5">
                                        5
                                    </a>
                                                                                                        
                    
                                            <a href="http://tabapp.test/admin/departments?sort_order=desc&amp;showSoftDeleted=0&amp;page=3" rel="next" class="relative inline-flex items-center px-2 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-r-md leading-5 hover:text-gray-400 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-500 transition ease-in-out duration-150" aria-label="Next &amp;raquo;">
                            <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
                                <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"></path>
                            </svg>
                        </a>
                                    </span>
            </div>
        </div>
    </nav>

                            </div>

I need server-side pagination, because there will be a lot of data coming from the backend that is to be rendered. Only client-side DataTable is getting fairly slow when the number of rows getting more than 1K.

Otherwise, I will need to consider creating custom CRUDs for many of my models that need such data handling.


Solution

  • Simple, In your AppServiceProvider file insert both lines:

    use Illuminate\Pagination\Paginator;
    
    public function boot(){
        Paginator::useBootstrap();
    }