Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Issue with Laravel 8 pagination link() method

Im trying to find out why blade isn't working right with this method and not showing properly in my webserver:

enter image description here

{{$posts->links()}}

Then this is my controller method who gets the data from the database and gives to the view the data

public function index(){
    $posts = Post::orderBy('created_at','desc')->paginate(5);
    return view('dashboard.post.index',['posts' => $posts]);
}
like image 206
Eloi Baulenas Avatar asked Oct 25 '25 02:10

Eloi Baulenas


2 Answers

what worked for me was adding the following to the app/Providers/AppServiceProvider.php file

//call paginator 
use Illuminate\Pagination\Paginator;

and then in the boot function add

Paginator::useBootstrap();

the file should look something like this

<?php

namespace App\Providers;

//call paginator 
use Illuminate\Pagination\Paginator;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //...
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //fix for pagination making weird oversize by using bootstraps paginator
        Paginator::useBootstrap();
    }
}
like image 114
ruan viviers Avatar answered Oct 27 '25 16:10

ruan viviers


I was stuck on this issue as well, I use the below solution and it worked fine for me on laravel 8. Hope it will be helpful.

{!! $posts->links('pagination::bootstrap-4') !!}
like image 32
Amir Khan Avatar answered Oct 27 '25 16:10

Amir Khan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!