Search code examples
phplaravelpaginationlaravel-5.3

hide pagination links if there is just one page in laravel


I am using laravel 5.3.

I know that how can paginate large data set and how to work it.

Pagination links shown Even if just one page is require to show result. but I want to hide pagination links in this case?

I use render() method to show pagination links like this :

<nav id="pagination">
  {!! $posts->render() !!}
</nav>

Any idea?


Solution

  • Because I want to apply this behavior to all paginations on the whole laravel project ,I used @Vuldo suggested approach to default.blade.php view in the resources/views/vendor/pagination directory like this :

    @if($paginator->total() > $paginator->perPage())
         <ul class="pagination">
            ...
         </ul>
    @endif