title: Laravel 5 Eloquent scope join and select specific columns
body: <p>I have an Eloquent model and in the model I am using a scope query to do a join.  This all works fine but I am trying to figure out how in the scope query to select only certain columns from the joined table.</p>
  
  <p>Here is the method in my controller.</p>
  
  <pre><code>$accounts = Account::creator()-&gt;get();
  </code></pre>
  
  <p>Here is the scope query in the model</p>
  
  <pre><code>public function scopeCreator($query) {
          $query-&gt;leftJoin('users','users.id','=','accounts.creator_id');
  }
  </code></pre>
  
  <p>This works but it returns <strong>all</strong> the columns from accounts and users but I only want all the columns from accounts and only 2 columns from users.</p>
  
  <p>I tried this...</p>
  
  <pre><code>public function scopeCreator($query) {
          $query-&gt;leftJoin('users','users.id','=','accounts.creator_id')-&gt;select(array('id','user_name'));
  }
  </code></pre>
  
  <p>However this returns only those 2 fields from users and ignores the columns from accounts.  I know how to do this with 2 different models but that means I have to create a useless model.  This scope query functionality is great if I can just get this part figured out.</p>