title: Laravel relationships and indexes between Matches, Teams, Players
body: <p>I'm struggling thinking about using a clean way to set a working relationship in Laravel between three models.</p>
  
  <p>There are tons of <strong>Matches</strong>, which always contain <strong>2 Teams</strong> where every team has <strong>5 Players</strong>.<br>
  Note: Players aren't users, so every match will generate new teams and players.</p>
  
  <p><strong>Matches</strong></p>
  
  <pre><code>class Match extends Model
  {
      public function teams()
      {
          return $this-&gt;hasMany('App\Team');
      }
  }
  </code></pre>
  
  <p><strong>Teams</strong></p>
  
  <pre><code>class Team extends Model
  {
      public function players()
      {
          return $this-&gt;hasMany('App\Player');
      }
  
      public function match()
      {
          return $this-&gt;belongsTo('App\Match');
      }
  }
  </code></pre>
  
  <p><strong>Players</strong></p>
  
  <pre><code>class Player extends Model
  {
      public function team()
      {
          return $this-&gt;belongsTo('App\Team');
      }
  }
  </code></pre>
  
  <p>My problem is that I can't find a solution in the lovely Laravel documentation for using a database table with two indexes.<br>
  Specific: A matches entry has a winner and a looser team. How to tell this in eloquentish to Laravel?</p>
  
  <p><strong>Matches</strong></p>
  
  <pre><code>    Schema::create('matches', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;integer('winner_team_id')-&gt;index();
          $table-&gt;integer('looser_team_id')-&gt;index();
  </code></pre>
  
  <p><strong>Teams</strong></p>
  
  <pre><code>    Schema::create('teams', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;integer('player_1')-&gt;index();
          $table-&gt;integer('player_2')-&gt;index();
          $table-&gt;integer('player_3')-&gt;index();
          $table-&gt;integer('player_4')-&gt;index();
          $table-&gt;integer('player_5')-&gt;index();
  </code></pre>
  
  <p><strong>Players</strong></p>
  
  <pre><code>    Schema::create('players', function (Blueprint $table) {
          $table-&gt;increments('id');
  </code></pre>
  
  <p>Is this approach "unclean" or do I miss something obvious from the documentation like more relationship-based classes for the model?</p>
  
  <p>Do I have to set up more tables like "match_teams" and "team_players" for a manyToMany-relationships-approach?</p>