jerexbambex's avatar

Laravel 8 Pagination not showing in View

Pagination links not showing in view when I use paginate() but it only shows "Previous" and "Next" when I use simplePaginate(). Please I need help. It's still tailwind CSS that I am using.

0 likes
16 replies
jlrdw's avatar

Use paginate instead of simplepaginate to show more links.

Show the code where you are showing the links.

jerexbambex's avatar

When I use paginate(), the link() does not display in the view.

//this will not show the links view in the blade file
$blogs = Blog::with('category')->paginate(15);

//but this shows only previous and next
$blogs = Blog::with('category')->simplePaginate(15);


This is for the view

{{ $blogs->links() }}

//I also tried this
{!! $blogs->links() !!}

jerexbambex's avatar

Yes, I did.

When I use paginate(), the link() does not display in the view.

//this will not show the links view in the blade file
$blogs = Blog::with('category')->paginate(15);

//but this shows only previous and next
$blogs = Blog::with('category')->simplePaginate(15);


This is for the view

{{ $blogs->links() }}

//I also tried this
{!! $blogs->links() !!}

vlade22's avatar

@jerexbambex I got the same problem but i solved it just wrapping {{ $blogs->links() }} into a and now works, hope to somebody helps this info

ldommer's avatar

Do you actually render the pagination in the blade template?

jerexbambex's avatar

When I use paginate(), the link() does not display in the view.

//this will not show the links view in the blade file
$blogs = Blog::with('category')->paginate(15);

//but this shows only previous and next
$blogs = Blog::with('category')->simplePaginate(15);


This is for the view

{{ $blogs->links() }}

//I also tried this
{!! $blogs->links() !!}

jlrdw's avatar

Exactly what is not working? Do you have the styles loaded?

jerexbambex's avatar

Yes, it is loaded.

The "Next" and "Previous" button shows when I use simplePaginate()

MichalOravec's avatar
$blogs = Blog::with('category')->paginate(15);

dd($blogs->total()); // what do you get here?

If you get less than 16 items, pagination links will not be shown.

jerexbambex's avatar

I have 50 which is the total blog posts that I have

jlrdw's avatar
jlrdw
Best Answer
Level 75

Right click, view source, are they in the page there. Or use network tab.

Also try placing in a separate division.

Edit: @jerexbambex have you got this solved?

1 like
jerexbambex's avatar

Yes I just did. Thanks so much. I put the custom CSS file before the app.css file in the region of the template.

1 like
jerexbambex's avatar

I think I just got it.

I changed the CSS placement.

I had to put the custom CSS before the app.css file.

This worked. Thank you all for your prompt response. You are the best.

jlrdw's avatar

@jerexbambex can you show solved, that was my thought above, something with style was off.

2 likes
sanusi's avatar

You can follow this steps

  1. php artisan vendor:publish
  2. Select laravel-pagination number and Hit enter
  3. Inside AppServiceProvider

.. .. use Illuminate\Pagination\Paginator

.. .. Inside boot method

.. .. .. .. Paginator::useTailwind();

1 like

Please or to participate in this conversation.