title: Laravel Fluent query update or insert based on if row exists
body: <p>I have a Laravel Fluent query that looks like the following:</p>
  
  <pre><code>$query = DB::connection('mysql_users')-&gt;table('users_info');
  $exists = $query-&gt;where('email', '=', $user-&gt;email)-first();
  
  if(is_object($exists)) {
      // update email
  }
  else {
      // insert email
  }
  </code></pre>
  
  <p>The problem is, sometimes $exists is not an object even though the row does exist. I've also tried with is_null() and have had the same issue. What is the correct way to do this check?</p>