title: how to get previous record where another column is equal to
body: <p>This is how to get previous record but i want to add another 'where'</p>
  
  <pre><code>$previous = User::where('id', '&lt;', $user-&gt;id)-&gt;max('id');
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code>$previous = User::where(['anotherColumn'=&gt;$anotherColumn], ['id', '&lt;', $user-&gt;id])-&gt;max('id');
  </code></pre>
  
  <p>but gives the wrong record</p>
  
  <p>look at the picture below i want to get 578 where id &lt; 580 and document_id = 244</p>
  
  <p><a href="https://i.stack.imgur.com/mN2KE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mN2KE.png" alt="enter image description here"></a></p>