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

{{$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]);
}
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();
}
}
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') !!}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With