title: Dealing with null values in Laravel database query?
body: <p>I am finding that I often need to select a field, based on a condition other than the id.</p>
  
  <p>So, <code>$user = User::where('last_login', $lastLogin)-&gt;where('last_warning', $lastWarning)-&gt;get();</code> works perfectly.</p>
  
  <p>That is until you set one of the where's to allow nulls (let's do <code>last_login</code>).</p>
  
  <p>That is, it can either have a value or be null.</p>
  
  <p>That means you need to use one of two function <code>where()</code> or <code>whereNull()</code> and to do that you need to break the chain, so it becomes</p>
  
  <pre><code>$user = User::where('last_warning', $lastWarning);
  
  is_null($lastLogin) ? $user-&gt;whereNull('last_login') : $user-&gt;where('last_login', $lastLogin);
  
  $user = $user-&gt;get();
  </code></pre>
  
  <p>I am wondering if <code>where</code> has a way to deal with this? as currently if you pass <code>null</code> through to where you get <code>where column = null</code> which doesn't work!</p>