Issue
Here is my code where I am showing the paginations of my blog posts !!
<div class="clearfix">
{{ $posts->render() }}
<a class="btn btn-secondary float-right" href="#">Older Posts →</a>
</div>
Here is the controller where the pagination function is called.
public function index()
{
$posts = post::where('status',1)->paginate(2);
return view('user.blog',compact('posts'));
}
I have tried lot, but my pagination displayed but not properly styled !! Why ??
Solution
To display the pagination links in your blade view:
{{ $posts->links() }}
Or if you need to specify Bootstrap 4:
{{$posts->links("pagination::bootstrap-4")}}
Laravel docs: https://laravel.com/docs/5.5/pagination
Answered By - kerrin
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.