tehseen's avatar

With paginate how only i get the next and previous button pagination

I am using paginate to display product but the below works fine what i am looking is jut previous and next button only any idea ?

{{ $products->links("pagination::bootstrap-4") }}
0 likes
4 replies
bugsysha's avatar
bugsysha
Best Answer
Level 61
<a href="{{ $products->previousPageUrl()">Previous</a>
<a href="{{ $products->nextPageUrl() }}">Next</a>
1 like
ajithlal's avatar

or some custom html block like

<ul class="pagination">
    <li class="page-item"><a class="page-link" href="{{ $products->previousPageUrl() }}">Previous</a></li>
    <li class="page-item"><a class="page-link" href="{{ $products->nextPageUrl() }}">Next</a></li>
  </ul>
Maria30's avatar

@tehseen

this is an example:

in your Controller instead of paginate() method, you use simplePaginate()

  public function index()
{

  $products = Product::simplePaginate(3);


  return view('products.welcome', compact('products'));

}

and then in your view you use

{{ $products->links() }} 

you can find the views for pagination in your app at :vendor/laravel/framework/src/Illuminate/Pagination/resources/views

When you use simplePaginate() the simple views are used according to the ui you load(bootstrap or no)

Please or to participate in this conversation.