Say you have items [2,4,5,8,3] and you would like to get numbers around 5 which are 4 and 8. how do you do it in laravel thanks.
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
1.4m articles
1.4m replys
5 comments
57.0k users