title: Merge 'with' and 'whereHas' in Laravel 5
body: <p>I have this code in Laravel 5, using Eloquent, which is working perfectly:</p>
  
  <pre><code>$filterTask = function($query) use ($id) {
      $query-&gt;where('taskid', $id);
  };
  
  User::whereHas('submissions', $filterTask)-&gt;with(['submissions' =&gt; $filterTask])-&gt;get();
  </code></pre>
  
  <p>Basically the goal is to get only those users with their filtered submissions, which has any of them.
  However, it seems wasting to run both <strong>whereHas</strong> and <strong>with</strong> methods with the same callback function. Is there a way to simplify it?</p>
  
  <p>Thanks.</p>