title: When returning a Laravel model, how do I restrict columns while also using with()?
body: <p>I have a model User defined as below:</p>
  
  <pre><code>&lt;?php
  class User extends Eloquent {
  
  public function roles() {
    return $this-&gt;belongsToMany('Role');
  }
  </code></pre>
  
  <p>How do I write a query which will fetch only specific fields from <code>User</code>, along with all fields from each <code>Role</code>?¨ I do not want to use the <code>hidden</code> property on the <code>User</code> model, because in different cases I want different subsets of the fields.</p>
  
  <p>This works, but of course returns all fields from <code>User</code>:</p>
  
  <pre><code>$user = User::with('roles')-&gt;findOrFail($id);
  </code></pre>
  
  <p>This correctly limits the fields of <code>User</code> but returns nothing for the <code>roles</code> - just an empty array</p>
  
  <pre><code>$user = User::with('roles')-&gt;select(['name','email'])-&gt;findOrFail($id);
  </code></pre>
  
  <p>Any attempt to reference the <code>roles</code> field inside the select gives an error.</p>