/**
  * @param $teams
  * @param $matches
  * @param $result
  *
  * @dataProvider matchesProvider
  */
 public function testSerializerWithMatchesList($teams, $matches, $result)
 {
     /**
      * @var $tournament Tournament
      */
     $tournament = Factory::create(Tournament::class);
     $league = Factory::create(League::class);
     for ($i = 1; $i <= $teams; $i++) {
         TournamentTeam::forceCreate(['id' => $i, 'tournamentId' => $tournament->id, 'teamId' => array_get(Factory::create(Team::class, ['leagueId' => $league->id]), 'id')]);
     }
     foreach ($matches as $key => $match) {
         Match::create(['tournamentId' => $tournament->id, 'homeTournamentTeamId' => $match['homeTeamId'], 'awayTournamentTeamId' => $match['awayTeamId'], 'homeScore' => $match['homeScore'], 'awayScore' => $match['awayScore'], 'homePenaltyScore' => 0, 'awayPenaltyScore' => 0, 'resultType' => $match['resultType'], 'gameType' => Match::GAME_TYPE_GROUP_STAGE, 'status' => Match::STATUS_FINISHED, 'round' => $key]);
     }
     $serializer = new StandingsSerializer();
     $collection = $serializer->collection(Match::where(['tournamentId' => $tournament->id])->get());
     foreach ($result as $teamScore) {
         $item = $collection->first(function ($key, $item) use($teamScore) {
             return $item['teamId'] == $teamScore['team'];
         });
         $this->assertEquals($item['position'], $teamScore['position']);
     }
 }
 public function standings()
 {
     $serializer = new StandingsSerializer();
     $collection = Match::with(['homeTournamentTeam.team', 'awayTournamentTeam.team'])->where(['tournamentId' => Input::get('tournamentId')]);
     return $this->response->collection($serializer->collection($collection->get()), new StandingsTransformer(), 'standing');
 }