title: Laravel - Merge two Queries?
body: <p>I am building a Twitter-like application which has a feed in it. In this feed I need to display shares with this properties:</p>
  
  <p>-Shares from user, who I am following</p>
  
  <p>-Shares from user, which are sorted by the positive rating, but only the top10%</p>
  
  <p>These two queries I need somehow to merge, so it will become an array in the end, which has all the shares which are applying to this criteria, without any duplicates and ordered by ID, desc</p>
  
  <p>My tables are looking like this:</p>
  
  <pre><code>User, Shares, Follows
  
  Shares:
  -user_id
  -positive
  
  Follows:
  -follower_id
  -user_id
  -level
  </code></pre>
  
  <p>What I already tried:</p>
  
  <pre><code>$follower_shares = Share::join('follows', 'shares.user_id', '=', 'follows.user_id')
          -&gt;where('follows.follower_id', Auth::user()-&gt;id)
          -&gt;where('follows.level', 1)
          -&gt;get(array('shares.*'));
  
  
  //count = 10% of total shares
  $count = Share::count()/10;
  $count = round($count);
  
  
  $top10_shares = Share::orderBy('positive', 'DESC')
  -&gt;take($count)
  -&gt;get();
  
  
  //sorts by id - descending
  $top10_shares = $top10_shares-&gt;sortBy(function($top)
  {
      return -($top-&gt;id);
  });
  
  
  //merges shares
  $shares = $top10_shares-&gt;merge($follower_shares);
  </code></pre>
  
  <p>The problem is now, that I was told that there is a better way to solve this.
  Also, $shares is giving me the result which applies to the criteria, but the shares have duplicates (rows, which are applying to both criteria) and arent ordered by id desc in total.</p>
  
  <p>I would be very happy, if you could tell me, how to do this the right way.</p>
  
  <p>Thanks very much!</p>