DEV Community

Cover image for Laravel Pagination
shani singh
shani singh

Posted on

2 1

Laravel Pagination

In this post I am going to explain you about using pagination with bootstrap.

Laravel By default come with Tailwind CSS Pagination Component. To use the Bootstrap Pagination We need to change the AppServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\Paginator;

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

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Paginator::useBootstrap();
    }
}

Enter fullscreen mode Exit fullscreen mode

To make a collection object pagination friendly we need to use pagination methods.

To use The Simple Pagination we can update the controller.

$users = User::select('id', 'email', 'name')->simplePaginate(5);
Enter fullscreen mode Exit fullscreen mode

In List View table we can simply output the pagination links

{{ $users->links() }}
Enter fullscreen mode Exit fullscreen mode

The Output will look like.
Simple Pagination

For Pagination with numbers we need to change the collection pagination method.

$users = User::select('id', 'email', 'name')->paginate(5);
Enter fullscreen mode Exit fullscreen mode

The Output will look like
Numeric Pagination

Get Code on Techtool Github

You can watch this video I have explained this.

Thank You for Reading

Reach Out To me.
Twitter
Instagram
TechToolIndia

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay