title: Laravel Eloquent Union query
body: <p>So I have the following query:</p>
  
  <pre><code>$a = Model::where('code', '=', $code)
      -&gt;where('col_a', '=' , 1)
      -&gt;orderBy(DB::raw('FIELD(layout, "normal", "split", "flip", "double-faced", "") ASC, layout'))
  
  $b = Model::where('code', '=', $code)
      -&gt;where('col_b', '=' , 1)
      -&gt;orderBy(DB::raw('FIELD(layout, "normal", "split", "flip", "double-faced", "") ASC, layout'))
  
  $a-&gt;union($b)-&gt;get();
  </code></pre>
  
  <p>No sorting is happening when I 'orderBy()' first and then union.</p>
  
  <p>When I do query '$a' or '$b' individually the 'orderBy()' works fine.</p>
  
  <p>When I do it in the following way 'orderBy()' happens as a whole.</p>
  
  <pre><code>$a-&gt;union($b)
      -&gt;orderBy(DB::raw('FIELD(layout, "normal", "split", "flip", "double-faced", "") ASC, layout'))
      -&gt;get();
  </code></pre>
  
  <p>How can I make it so the 'orderBy()' applies for each individually and then union the results back? It seems like it should work.</p>
  
  <p>EDIT: If anyone can provide a way to do this, even if it's normal MySQL, I will choose yours as the answer as I think there may be a bug with Eloquent.</p>