How to check if used paginate in laravel

Try like this

@if($products instanceof \Illuminate\Pagination\AbstractPaginator)

   {{$products->links()}}

@endif

You need to check wheater the $products is instance of Illuminate\Pagination\AbstractPaginator. It can be an array or Laravel's Collection as well.


@if($threads->hasPages())
  {{ $threads->links() }}
@endif

Simple one!


This works perfectly. Check if $products is an instance of Illuminate\Pagination\LengthAwarePaginator then display the pagination links.

@if($products instanceof \Illuminate\Pagination\LengthAwarePaginator )

   {{$products->links()}}

@endif

As of laravel 7 you can now do this:

@if( $vehicles->hasPages() )
   {{ $vehicles->links() }}
@endif