private static function generateAppearances($teamIds, $matchId) { foreach ($teamIds as $id) { $players = Player::where('team_id', $id)->get()->random(11); foreach ($players as $player) { MatchPlayer::create(['match_id' => $matchId, 'team_id' => $id, 'player_id' => $player->id, 'vote' => Randomizer::voteFromSkill($player->skillAvg)]); } } }