Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Pagination is showing weird arrows

So I used simple Laravel pagination command of {{$posts->links()}} displaying 5 posts on one page. Laravel's pagination is doing its job but it is displaying weird arrows. Refer the image below and please if someone is willing to help can ask me for codes I will share them. a

like image 295
Xtinct Avatar asked Sep 22 '20 03:09

Xtinct


People also ask

How does Laravel pagination work?

The pagination option specifies which view should be used to create pagination links. By default, Laravel includes two views. The pagination::slider view will show an intelligent "range" of links based on the current page, while the pagination::simple view will simply show "previous" and "next" buttons.

Can you paginate a collection in Laravel?

Laravel provides pagination out of the box for Eloquent Collections, but you can't use that by default on ordinary Collections. Collections do have the forPage() method, but it's more low-level, so it doesn't generate pagination links. So you have to create a LengthAwarePaginator instance.


2 Answers

Here is official document that talk about it. You can check it

Inside AppServiceProvider


use Illuminate\Pagination\Paginator;

public function boot()
{
    Paginator::useBootstrap();
}

Doc: https://laravel.com/docs/8.x/pagination#using-bootstrap

Sample implementation: https://www.itsolutionstuff.com/index.php/post/laravel-8-pagination-example-tutorialexample.html

like image 171
Sok Chanty Avatar answered Oct 09 '22 16:10

Sok Chanty


I put as an argument on the "links" method, a version of Bootstrap which works right:

$posts->links('pagination::bootstrap-4')
like image 29
Fernando Lz Avatar answered Oct 09 '22 14:10

Fernando Lz