title: I want to find top 10 favorite trails in laravel queries
body: <p>I have two tables named 'favorites' and 'trails'. I want to show top 10 favorites trails for users. I made 'many to many' relationship between them. But, I am not sure how to make the query.What should be the right query.Would someone help me for the right one.  Without relationship, I tried something like this-</p>
  
  <pre><code>$favorites = DB::table('favorites')
                                    -&gt;join('trails', 'trails.id', '=', 'favorites.trail_id')
                                    -&gt;select('favorites.trail_id', 'trails.name')
                                    -&gt;get();
  </code></pre>
  
  <p>First one is 'trails' table and another one is 'favorites' bellow -</p>
  
  <p><a href="https://i.stack.imgur.com/2MdPX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2MdPX.jpg" alt="trails"></a></p>
  
  <p><a href="https://i.stack.imgur.com/av5L4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/av5L4.jpg" alt="favorites"></a></p>