title: Custom sorting on a laravel relationship collection
body: <p>I'm a little stuck on something that usually is quite straight forward. I need to sort records from a hasMany relationship into a custom order based on a certain value and an 'sort order' array. </p>
  
  <p>My code below doesn't work because I'm passing uSort() a eloquent collection and I'm not sure how to get around it.</p>
  
  <pre><code>$go = $this-&gt;hasMany('Product')-&gt;orderBy('colour','DESC');
  
  $order = array('RED', 'GREEN', 'BLUE', 'YELLOW');
  
  usort($go, function ($a, $b) use ($order) {
      $pos_a = array_search($a-&gt;colour, $order);
      $pos_b = array_search($b-&gt;colour, $order);
      return $pos_a - $pos_b;
  });
  
  return $go;
  </code></pre>
  
  <p>Maybe I'm missing some amazing laravel magic helper, but I'm stuck. Any thoughts or advice would be much appreciated!</p>
  
  <p>Cheers</p>