title: Running a query and ordering on an avg.
body: <p>I am trying to get all products from my database and order them on their reviews avg rating and not the product name. How would i go about this in my controller?</p>
  
  <p>Tables- <strong>Product</strong>: id, name, price, 
  <strong>Reviews</strong>: id,  reviews, ratings, product_id</p>
  
  <p>This is how im showing on my query blade. </p>
  
  <pre><code>&lt;p&gt;{{$product-&gt;reviews-&gt;avg('ratings')}}/ 5&lt;/p&gt;
  </code></pre>
  
  <p>Current Controller: </p>
  
  <pre><code>$products =Product::orderBy('name');
  </code></pre>