This solved my problem
public function show(Blog $blog)
{
$next = Blog::where('id', '>', $blog->id)
->oldest('id')
->first();
$previous = Blog::where('id', '<', $blog->id)
->latest('id')
->first();
return view('dashboard.Blog.show',compact('blog','previous','next'));
}
laravel-getting-the-previous-and-next-records
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…