Laravel 5.5 & Bootstrap 4 Pagination Issues

Published 8 months ago by HFH

I've seen a number of threads regarding the class changes in pagination from BS3 to BS4, but I can't seem to get to the bottom of it on my own app.

Using a simple pagination in my controller with:

$users = DB::table('users')->orderBy('created_at', 'desc')->simplePaginate(5);

And then rendering the pagination buttons as such:

{{ $users->render() }}

Gives me unstyled links, instead of normal buttons.

MustafaAgamey

same issue , any solutions ?

jdunsmore

Can you explain why you're using

{{$users->render()}}

Instead of

{{$users->links()}}

?

skeith22

use

{{ $users->links('vendor.pagination.bootstrap-4') }}

you're welcome

Maung-C

Change your controller.php $users = DB::table('users')->orderBy('created_at', 'desc')->simplePaginate(5); to $users = DB::table('users')->orderBy('created_at', 'desc')->paginate(5);

and then you can use {{ $users->render() }} or {{ $users->links() }} for your view pagination simplePaginate() method is show next and previous link only.

mballaag

@HFH @MustafaAgamey use

 {{ $users->links() }} 

Remember, the HTML generated by the links method is compatible with the Bootstrap CSS framework

aungthet

https://laravel.com/docs/5.6/pagination#customizing-the-pagination-view

use Illuminate\Pagination\Paginator;

public function boot() {

Paginator::defaultView('pagination::view');

Paginator::defaultSimpleView('pagination::view');

}

For bootstrap 4 ,

Paginator::defaultView('pagination::bootstrap-4');

pardeepkumar

For Controller

public function index()
    {
        $users = DB::table('users')->paginate(15);

        return view('user.index', ['users' => $users]);
    }

For View


    @foreach ($users as $user)
        {{ $user->username }}
    @endforeach

{{ $users->links() }}

Please sign in or create an account to participate in this conversation.