title: Yii2 ORDER BY for relational data in ActiveRecord
body: <p>I have a query in my controller:</p>
  
  <pre><code>$model = Object::find()-&gt;where(['id' =&gt; $id])-&gt;with(['backups'])-&gt;one();
  </code></pre>
  
  <p>getBackups is a hasMany() relation, so $model returns several 'backups'.</p>
  
  <p>Is there a way to order the 'backups'?</p>
  
  <p>I have tried the following without results (or errors):</p>
  
  <pre><code> $model = Object::find()
            -&gt;where(['id' =&gt; $id])
            -&gt;with(['backups' =&gt; function($query) { 
                $query-&gt;orderBy(['updated_at' =&gt; SORT_DESC]); 
            }])
            -&gt;one();
  </code></pre>