Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pagination not styled in laravel 5.5

Here is my code where I am showing the paginations of my blog posts !!

<div class="clearfix">
    {{ $posts->render() }}
    <a class="btn btn-secondary float-right" href="#">Older Posts &rarr;</a>
</div>

Here is the controller where the pagination function is called.

public function index()
{
    $posts = post::where('status',1)->paginate(2);
    return view('user.blog',compact('posts'));
}

I have tried lot, but my pagination displayed but not properly styled !! Why ??

Here I show what is happening above the black line !!

like image 453
Muhammad Hamza Avatar asked Oct 07 '17 07:10

Muhammad Hamza


People also ask

How can we manually create pagination in Laravel?

Creating A Paginator Manually Sometimes you may wish to create a pagination instance manually, passing it an array of items. You may do so by creating either an Illuminate\Pagination\Paginator or Illuminate\Pagination\LengthAwarePaginator instance, depending on your needs.

How can I get pagination in Laravel?

There are several ways to paginate items. The simplest is by using the paginate method on the query builder or an Eloquent query. The paginate method provided by Laravel automatically takes care of setting the proper limit and offset based on the current page being viewed by the user.

How does pagination work in Laravel?

Pagination works by selecting a specific chunk of results from the database to display to the user. The total number of results is calculated and then split between pages depending on how many results you want to return on a page.


1 Answers

For Laravel 8

Laravel includes pagination views built using Bootstrap CSS. To use these views instead of the default Tailwind views, you may call the paginator's useBootstrap method within the boot method of your App\Providers\AppServiceProvider class:

use Illuminate\Pagination\Paginator;

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

Laravel docs: https://laravel.com/docs/8.x/pagination

like image 102
migsAV Avatar answered Oct 20 '22 20:10

migsAV