Order by relationship column
<p>I have the following query:</p>

<pre><code>$items = UserItems::with('item')
        -&gt;where('user_id','=',$this-&gt;id)
        -&gt;where('quantity','&gt;',0)
        -&gt;get();
</code></pre>

<p>I need to order it by item.type so I tried:</p>

<pre><code>$items = UserItems::with('item')
        -&gt;where('user_id','=',$this-&gt;id)
        -&gt;where('quantity','&gt;',0)
        -&gt;orderBy('item.type')
        -&gt;get();
</code></pre>

<p>but I get  <code>Unknown column 'item.type' in 'order clause'</code></p>

<p>What I am missing?</p>