title: How to update specific rows using laravel
body: <p>I have a table:</p>
  
  <pre><code>ID|user_id|group_id|subject |book_id|duplicate
   1| 2     |3       |history |1      |         
   2| 4     |3       |history |1      |
   3| 5     |3       |history |1      |
  </code></pre>
  
  <p>I want the resulting table to look like this:</p>
  
  <pre><code>ID|user_id|group_id|subject |book_id|duplicate
   1| 2     |3       |history |1      |         
   2| 4     |3       |history |1      |1
   3| 5     |3       |history |1      |1
  </code></pre>
  
  <p>I want all ascending IDs after the lowest <code>ID</code> duplicate column to be updated to 1. PLEASE NOTE: the IDs are dynamic and so simply using <code>-&gt;where(ID, '&gt;', 1);</code> will not work in all cases.</p>
  
  <p>so far I have this</p>
  
  <pre><code>$duplicates = DB::table('table')
                 -&gt;where('subject', 'history')
                 -&gt;where('book_id', 1)
               -&gt;skip(1)-&gt;take(1)
              -&gt;update(['duplicate' =&gt; 1]);
  </code></pre>
  
  <p>The code above does not work because I get a resulting table that looks like this:</p>
  
  <pre><code>ID|user_id|group_id|subject |book_id|duplicate
   1| 2     |3       |history |1      | 1        
   2| 4     |3       |history |1      |
   3| 5     |3       |history |1      |
  </code></pre>