Next Previous Link Button Pagination in Laravel

Websolutionstuff | Jun-14-2021 | Categories : Laravel

Today we will learn next previous link button pagination in laravel, Using paginate method you can easily create pagination in laravel.

Here i will show you laravel next and prev pagination with example, we can create customize next and previous pagination link in Laravel sso let's see how to create pagination in laravel 8.

If you only need to display simple "Next" and "Previous" links in your website , then you can use the simplePaginate method to perform a single, efficient query.

Example 1 : 

1) create controller and add below code.

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Post;
class PostController extends Controller
    public function index()
        $posts = Post::simplePaginate(10);
        return view('posts.index', compact('posts'));


2) create blade file.

      <title>Next Previous Link Button Pagination in Laravel -</title>
      <link rel="stylesheet" href=""/>
      <div class="container">
         <h1>Next Previous Link Button Pagination in Laravel -</h1>
         <table class="table table-bordered">
               @foreach($posts as $post)
                  <td>{{ $post->id }}</td>
                  <td>{{ $post->title }}</td>
         <div class="paginationWrapper">
            {{ $posts->links() }}


Example 2 :

   @if($posts->currentPage() > 1)
      <a href="{{ $posts->previousPageUrl() }}">Previous</a>
      <a href="{{ $posts->nextPageUrl() }}">Next</a>



Recommended Post
Featured Post
How to Create Slider using jQuery
How to Create Slider using jQu...

In this post we will see how to create slider using jquery, here we will use owl carousel for create slider using b...

Read More


How To Auto Select Country Using IP Lookup In jQuery
How To Auto Select Country Usi...

In this article, we will see how to auto select a country using IP lookup in jquery. Here, we will learn about auto...

Read More


PHP 8.3: Release Date and New Features
PHP 8.3: Release Date and New...

Welcome web development enthusiasts! Here, we are going to talk about the much-awaited PHP 8.3. It is packed with a m...

Read More


How To Install TinyMCE Editor In Laravel
How To Install TinyMCE Editor...

In this article, I will give you an example of the TinyMCE editor, Tinymce editor is a rich-text open-source editor,&nbs...

Read More