How can I make different paginations in single page?
This is the controller:
public function index()
{
$posts = Post::orderBy('created_at', 'DESC')->paginate(5);
$categories = Category::all();
$randomPosts = RandomPost::orderByRaw("RAND()")->paginate(2);
return view('posts.index', compact('posts', 'categories','randomPosts'));
}
When I'm in a page, and let' say click second page then both paginations change to second page. What I want to do here is to make that when I press second page on $posts then the $randomPosts will still stay in 1st page and not in the 2nd. I can't find a way how to do that on Laravel 5.1 version.
All in all I want to make two seperate paginations in one single page.