title: Laravel treat pivot table as model with relations
body: <p>I am new to laravel and still a little bit confused about relations.</p>
  
  <p>I have two models: Tournament and Season with many to many relations.</p>
  
  <pre><code>Schema::table('tournaments', function(Blueprint $table)
  {
      $table-&gt;increments('id')-&gt;unsigned();
      $table-&gt;string('name')-&gt;unique();
  });
  
  Schema::table('seasons', function(Blueprint $table)
  {
      $table-&gt;increments('id')-&gt;unsigned();
      $table-&gt;string('name')-&gt;unique();
  });
  </code></pre>
  
  <p>and the pivot table </p>
  
  <pre><code>Schema::table('season_tournament', function(Blueprint $table)
  {
      $table-&gt;integer('season_id')-&gt;unsigned();
      $table-&gt;integer('tournament_id')-&gt;unsigned();
      $table-&gt;primary(['season_id','tournament_id']);
  });
  </code></pre>
  
  <p>And relations described in Models like</p>
  
  <pre><code>//Tournament model
  public function seasons()
  {
      return $this-&gt;belongsToMany('App\Season');
  }
  
  //Season model
  public function tournaments()
  {
      return $this-&gt;belongsToMany('App\Tournament');
  }
  </code></pre>
  
  <p>And everything works perfect until I need to add a new model - Event, with next relations:
  Any tournament in any season can have separate events. So each season_tournament record can have many events, and each event should belongs to exact season_tournament record. So when I run the next code:</p>
  
  <pre><code>Tournament::first()-&gt;seasons()-&gt;latest()-&gt;first()-&gt;events;
  </code></pre>
  
  <p>I should not get all events from the whole season, but from pair tournament_season.</p>
  
  <p>So basically it looks like I need extended pivot with 3 columns like:</p>
  
  <pre><code>Schema::table('event_season_tournament', function(Blueprint $table)
  {
      $table-&gt;integer('event_id')-&gt;unsigned();
      $table-&gt;integer('season_id')-&gt;unsigned();
      $table-&gt;integer('tournament_id')-&gt;unsigned();
      $table-&gt;primary(['event_id','season_id','tournament_id']);
  });
  </code></pre>
  
  <p>Is there any built-in methods to manage such things? Or maybe there are more simple solutions?</p>