title: Laravel 5.3 previous and next record link
body: <p>I have found a solution for next and previous records links in database.But the solution is only working good for next record.When i press back link , it shows first record.Can you help me to find a solution for showing biggest number of previous records?</p>
  
  <pre><code>//Model file
  
  public static function findNext($id)
  {
      return static::where('id','&gt;',$id)-&gt;first();
  }
  public static function findPrevious($id)
  {
      return static::where('id','&lt;',$id)-&gt;first();
  }
  
  //Controller file
  
  public function show($id)
  {
  $c = C::findOrFail($id);
  $nextUser = C::findNext($id);
  $previousUser = C::findPrevious($id);
      return view('c.show', compact('c',$c))-&gt;with('nextUser',$nextUser)-
  &gt;with('previousUser',$previousUser);
      }
  
  //View file
  
  @if($previousUser)
  &lt;a href="{{ URL::to( 'c/show/' . $previousUser-&gt;id . '/previous') 
  }}"&gt;Previous&lt;/a&gt; | 
  @endif
  @if($nextUser)
  &lt;a href="{{ URL::to( 'c/show/' . $nextUser-&gt;id . '/next') }}"&gt;Next&lt;/a&gt;
  @endif
  
  //Route file
  
  Route::get('c/show/{id}', 'CController@show');
  Route::get('c/show/{user}/next',function($id){
  $nextUser=C::findNext($id);
  return Redirect::to('c/show/'.$id);
  });
  Route::get('c/show/{user}/previous',function($id){
  $nextUser=C::findPrevious($id);
  return Redirect::to('c/show/'.$id);
  });
  </code></pre>