title: Laravel - Merge Two Relationship gives an error
body: <p>Using Laravel 5.4, I have a table <strong>Teams</strong> and another table <strong>Matches</strong>
  Each match has <strong>TEAM HOME ID</strong> and <strong>TEAM AWAY ID</strong></p>
  
  <p>I found this great trick to merge in such cases to find all the matches played by a team either at home or away. But it does not seem to work.</p>
  
  <p><a href="https://stackoverflow.com/questions/24184069/laravel-merge-reltationships">Laravel merge reltationships</a></p>
  
  <pre><code>/**
   * The matches that this team has played at home.
   */
  public function matchesHome()
  {
      return $this-&gt;hasMany('App\Match', 'team_home_id', 'id');
  }
  
  /**
   * The matches that this team has played away.
   */
  public function matchesAway()
  {
      return $this-&gt;hasMany('App\Match', 'team_away_id', 'id');
  }
  
  /**
   * The matches that this team has played.
   */
  public function matches()
  {
      $matchesPlayedHome = $this-&gt;matchesHome();
      $matchesPlayedAway = $this-&gt;matchesAway();
  
      // Merge collections and return single collection.
      return $matchesPlayedHome-&gt;merge($matchesPlayedAway);     // cannot get this to work | Call to undefined method Illuminate\Database\Query\Builder::merge()
  }
  </code></pre>
  
  <p>The error I am getting is <strong>Call to undefined function merge</strong>
      Call to undefined method Illuminate\Database\Query\Builder::merge()</p>
  
  <p>Please help
  Thanks</p>
  
  <p>..................</p>
  
  <p>I have even tried eager loading, in that case the error becomes</p>
  
  <p><strong>Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation</strong></p>
  
  <pre><code>public function matches()
  {
      $matches = Team::with('matchesHome', 'matchesAway')-&gt;get();
      return $matches;
  }
  </code></pre>