title: Laravel Orderby not working inside Eloquent whereHas relationship?
body: <p>Please have look on below code.</p>
  
  <pre><code> $serviceNew = CompletedService::selectRaw('gallons_collected as total,account_id,id,service_provider_id,service_id,service_date')
              -&gt;where("service_id", '1')-&gt;where('service_provider_id', $service_privider_id)-&gt;whereMonth('service_date', $month)-&gt;whereYear('service_date', $year)
              -&gt;with('account')
              -&gt;whereHas('account', function($qs) {
                  $qs-&gt;orderBy('restaurant_name', 'DESC');
              })
              -&gt;get();
  </code></pre>
  
  <p>I have multiple records in "CompletedService" and there is one parent id account_id which in account table. and i made with on account.</p>
  
  <p>Already ASC and DESC tried.</p>
  
  <p>Try to order by in whereHas but it's not affect on any records.
  Below is model relationship.</p>
  
  <pre><code> public function account() {
      return $this-&gt;hasOne('App\Account', 'id', 'account_id');
  }
  </code></pre>
  
  <p>i don't need to orderby in model because i used this relation in multiple time and need only order by in this single query.</p>
  
  <p><strong>And one completed service records relations have only one account.
  So basically i need to sort completed service records on the account field.</strong></p>
  
  <p>Output
  <a href="https://i.stack.imgur.com/lL2z1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lL2z1.png" alt="enter image description here"></a></p>
  
  <p>Tables</p>
  
  <p><strong>CompletedService</strong></p>
  
  <pre><code>|id| account_id|service_id|service_provider_id|gallons_collected|service_date
  |1 | 2         | 1        | 9                 | 50              | 2017-08-29
  </code></pre>
  
  <p><strong>Accounts</strong></p>
  
  <pre><code>| id | restaurant_name|
  </code></pre>
  
  <p><strong>Every help will be appreciated.
  Thanks in advance.!</strong></p>