title: delete the duplicate records, and keep the one that have lower id
body: <h1>I have</h1>
  <p>a users table that contains bad data. I want to loop through and delete the duplicate records in term of <code>email</code>, and keep the record that have <code>lower</code> <strong>id</strong>.</p>
  <p><a href="https://i.stack.imgur.com/W31bh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W31bh.png" alt="enter image description here" /></a></p>
  <p>I want to keep only id : 1, 14, 1004, 1005, 1003, 1006, and 1007.</p>
  <hr />
  <h1>I've tried</h1>
  <pre><code>$users = DB::table('users')-&gt;where('id', DB::raw(&quot;(select min(`id`) from users)&quot;))-&gt;get();
  
  foreach ($users as $user) {
      if ( ???? )) { // &lt;---- I'm not sure what to put here. 
          $user-&gt;delete();
      }
  }
  </code></pre>
  <hr />
  <h1>I noticed</h1>
  <p><code>$users = DB::table('users')-&gt;groupBy('email')-&gt;get();</code></p>
  <p>return all the records I want to keep.</p>