title: Eloquent - where not equal to
body: <p>I'm currently using the latest Laravel version.</p>
  
  <p>I've tried the following queries:</p>
  
  <pre><code>Code::where('to_be_used_by_user_id', '&lt;&gt;' , 2)-&gt;get()
  Code::whereNotIn('to_be_used_by_user_id', [2])-&gt;get()
  Code::where('to_be_used_by_user_id', 'NOT IN', 2)-&gt;get()
  </code></pre>
  
  <p>Ideally, it should return all records except <code>user_id = 2</code>, but it returns blank array. How do I tackle this?</p>
  
  <pre><code>Code::all()
  </code></pre>
  
  <p>This returns all 4 records.</p>
  
  <p>Code model:</p>
  
  <pre><code>&lt;?php namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Code extends Model
  {
  
      protected $fillable = ['value', 'registration_id', 'generated_for_user_id', 'to_be_used_by_user_id', 'code_type_id', 'is_used'];
  
      public function code_type()
      {
          return $this-&gt;belongsTo('App\CodeType');
      }
  
  }
  </code></pre>