title: How to select columns from joined tables: laravel eloquent
body: <p>I have a different problem from <a href="https://stackoverflow.com/questions/14727038/laravel-eloquent-how-to-get-only-certain-columns-from-joined-tables">this</a>. The scenario is same but I am in need of more filtration of the results.</p>
  
  <p>Let me explain.</p>
  
  <p>Consider I have 2 tables</p>
  
  <p>vehicles</p>
  
  <pre><code> id
   name
   staff_id
   distance
   mileage
  </code></pre>
  
  <p>staffs</p>
  
  <pre><code> id
   name
   designation
  </code></pre>
  
  <p>I want to select only <code>id</code> and <code>name</code> from both tables(Models).
  The Vehicle Model contain a <code>belongsTo</code> relation to Staff model.</p>
  
  <pre><code>class Vehicle extends Model
  {
      public function staff()
      {
        return $this-&gt;belongsTo('App\Staff','staff_id');
      }
  }
  </code></pre>
  
  <p>and I joined using this</p>
  
  <pre><code>Vehicle::where('id',1)
              -&gt;with(['staff'=&gt; function($query){
                              // selecting fields from staff table
                              $query-&gt;select(['staff.id','staff.name']);
                            }])
              -&gt;get();
  </code></pre>
  
  <p>When I put fields in <code>-&gt;get()</code> like this</p>
  
  <pre><code>-&gt;get(['id','name'])
  </code></pre>
  
  <p>it filters the <code>vehicle</code> table but produce no result of Staff table.</p>
  
  <p>Any ideas?</p>