title: Eloquent is setting a value to null
body: <p>i'm having an error with Eloquent (and Many to Many relationship).
  This is my code:</p>
  
  <pre><code>$user = new Users;
  $rs = $user
      -&gt;company()
      -&gt;where('company_role.users_id', $request-&gt;session()-&gt;get('usrid'))
      -&gt;where('code', $request-&gt;company)
      -&gt;first();
  </code></pre>
  
  <p>The query that Eloquent perform is this one:</p>
  
  <pre><code>select `companies`.*, `company_role`.`users_id` as `pivot_users_id`, `company_role`.`companies_id` as `pivot_companies_id`, `company_role`.`role_name` as `pivot_role_name` from `companies` inner join `company_role` on `companies`.`id` = `company_role`.`companies_id` where `company_role`.`users_id` is null and `company_role`.`users_id` = 1 and `code` = 12345678901 limit 1)"
  </code></pre>
  
  <p>How is this possible? Do you guys have any idea? <br></p>
  
  <p>This is my Users model:</p>
  
  <pre><code>class Users extends Model
  {
      //table associated with model
      protected $table = 'users';
      protected $primaryKey = 'id';
  
      public function company(){
          return $this-&gt;belongsToMany('App\Companies','company_role')-&gt;withPivot('role_name');
      }
  }
  </code></pre>