@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | //Create Player data |
| 65 | 65 | $matchUp = array(); |
| 66 | - foreach($groupPlayers as $key=>$groupPlayer){ |
|
| 66 | + foreach($groupPlayers as $key=>$groupPlayer) { |
|
| 67 | 67 | $matchUp[$key]['player'] = $groupPlayer->pivot->player_id; |
| 68 | 68 | $matchUp[$key]['matchHandicap'] = round($groupPlayer->pivot->handicap ,0); |
| 69 | - foreach ($groupPlayer->round as $round){ |
|
| 69 | + foreach ($groupPlayer->round as $round) { |
|
| 70 | 70 | $matchUp[$key]['team'] = $round->team_id; |
| 71 | 71 | $matchUp[$key]['course'] = $round->course_id; |
| 72 | 72 | $matchUp[$key]['holescores'] = $round->holescores; |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // Change lowest handicap to ZERO and change others to reflect it |
| 78 | - foreach($matchUp as $key=>$match){ |
|
| 78 | + foreach($matchUp as $key=>$match) { |
|
| 79 | 79 | $matchHandicaps[] = $match['matchHandicap']; |
| 80 | 80 | } |
| 81 | 81 | $lowestMatchHandicap = min($matchHandicaps); |
| 82 | 82 | //handicap change |
| 83 | 83 | $handicapChange = $lowestMatchHandicap * -1; |
| 84 | - foreach($matchUp as $key=>$match){ |
|
| 84 | + foreach($matchUp as $key=>$match) { |
|
| 85 | 85 | $matchUp[$key]['matchHandicap'] = $match['matchHandicap'] + $handicapChange; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | $team1 = array(array_shift ($matchUp)); |
| 90 | 90 | $team1Id = $team1[0]['team']; |
| 91 | 91 | $team1Name = Team::select('name')->where('id', '=', $team1Id)->get()->toArray(); |
| 92 | - foreach($matchUp as $key=>$match){ |
|
| 93 | - if($match['team'] == $team1[0]['team']){ |
|
| 92 | + foreach($matchUp as $key=>$match) { |
|
| 93 | + if($match['team'] == $team1[0]['team']) { |
|
| 94 | 94 | $team1[] = $match; |
| 95 | 95 | unset($matchUp[$key]); |
| 96 | 96 | } |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | //Need to determine if same amount of scores are in both |
| 116 | 116 | // If not then do not return |
| 117 | 117 | |
| 118 | - foreach($team1Scores as $key=>$teamScore){ |
|
| 119 | - if($teamScore <= 0){ |
|
| 118 | + foreach($team1Scores as $key=>$teamScore) { |
|
| 119 | + if($teamScore <= 0) { |
|
| 120 | 120 | $team1Scores[$key] = ''; |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - foreach($team2Scores as $key=>$teamScore){ |
|
| 125 | - if($teamScore <= 0){ |
|
| 124 | + foreach($team2Scores as $key=>$teamScore) { |
|
| 125 | + if($teamScore <= 0) { |
|
| 126 | 126 | $team2Scores[$key] = ''; |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -161,11 +161,11 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | private function getTeamNetScore($team, $holesData) |
| 163 | 163 | { |
| 164 | - foreach($team as $key=>$item){ |
|
| 164 | + foreach($team as $key=>$item) { |
|
| 165 | 165 | // Create holes array for NET |
| 166 | 166 | $holes = array(); |
| 167 | 167 | $i = 1; |
| 168 | - foreach($holesData as $key=>$holeData){ |
|
| 168 | + foreach($holesData as $key=>$holeData) { |
|
| 169 | 169 | $holes[$i] = $holeData->handicap; |
| 170 | 170 | $i++; |
| 171 | 171 | } |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | 9 => 0 |
| 184 | 184 | ]; |
| 185 | 185 | //Create array of strokes |
| 186 | - for($counter = $item['matchHandicap']; $counter > 0; $counter--){ |
|
| 187 | - if($counter > 9){ |
|
| 186 | + for($counter = $item['matchHandicap']; $counter > 0; $counter--) { |
|
| 187 | + if($counter > 9) { |
|
| 188 | 188 | $newCounter = $counter - 9; |
| 189 | 189 | while($newCounter > 0) { |
| 190 | 190 | $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | // Plus handicaps don't hit previous loop so need its own |
| 198 | 198 | //Plus handicap logic |
| 199 | 199 | |
| 200 | - foreach($strokeArray as $strokeKey=>$stroke){ |
|
| 200 | + foreach($strokeArray as $strokeKey=>$stroke) { |
|
| 201 | 201 | $holeKey = array_search($strokeKey,$holes); |
| 202 | 202 | $holes[$holeKey] = $stroke; |
| 203 | 203 | } |
@@ -206,16 +206,18 @@ discard block |
||
| 206 | 206 | //get array of holescores |
| 207 | 207 | |
| 208 | 208 | $holeScores = $item['holescores']; |
| 209 | - foreach($holeScores as $key=>$holeScore){ |
|
| 209 | + foreach($holeScores as $key=>$holeScore) { |
|
| 210 | 210 | //check if new score is less PlayerScores |
| 211 | - if(isset($playerScores[$key])){ // 2nd time in for hole |
|
| 212 | - if($playerScores[$key] >= $holeScore['score']){ |
|
| 211 | + if(isset($playerScores[$key])) { |
|
| 212 | +// 2nd time in for hole |
|
| 213 | + if($playerScores[$key] >= $holeScore['score']) { |
|
| 213 | 214 | $playerScores[$key] = $holeScore['score'] - $holes[$key+1]; |
| 214 | 215 | } |
| 215 | - } else{ // first time in for hole |
|
| 216 | - if($holeScore['score'] != null){ |
|
| 216 | + } else { |
|
| 217 | +// first time in for hole |
|
| 218 | + if($holeScore['score'] != null) { |
|
| 217 | 219 | $playerScores[$key] = $holeScore['score'] - $holes[$key+1]; |
| 218 | - } else{ |
|
| 220 | + } else { |
|
| 219 | 221 | $playerScores[$key] = null; |
| 220 | 222 | } |
| 221 | 223 | } |
@@ -230,12 +232,12 @@ discard block |
||
| 230 | 232 | $points = 0; |
| 231 | 233 | $teamTotalPoints = 0; |
| 232 | 234 | $opponentTotalPoints = 0; |
| 233 | - foreach ($team as $key=>$score){ |
|
| 234 | - if($score != null){ |
|
| 235 | - if($score < $opponent[$key]){ |
|
| 235 | + foreach ($team as $key=>$score) { |
|
| 236 | + if($score != null) { |
|
| 237 | + if($score < $opponent[$key]) { |
|
| 236 | 238 | $points++; |
| 237 | 239 | } |
| 238 | - if($score == $opponent[$key]){ |
|
| 240 | + if($score == $opponent[$key]) { |
|
| 239 | 241 | $points = $points + .5; |
| 240 | 242 | } |
| 241 | 243 | } |
@@ -243,11 +245,11 @@ discard block |
||
| 243 | 245 | $opponentTotalPoints = $opponentTotalPoints + $points; |
| 244 | 246 | } |
| 245 | 247 | // Bonus point logic |
| 246 | - if($team[8] != null && $opponent[8] != null){ |
|
| 247 | - if($teamTotalPoints > $opponentTotalPoints){ |
|
| 248 | + if($team[8] != null && $opponent[8] != null) { |
|
| 249 | + if($teamTotalPoints > $opponentTotalPoints) { |
|
| 248 | 250 | $points = $points + 1; |
| 249 | 251 | } |
| 250 | - if($teamTotalPoints == $opponentTotalPoints){ |
|
| 252 | + if($teamTotalPoints == $opponentTotalPoints) { |
|
| 251 | 253 | $points = $points + .5; |
| 252 | 254 | } |
| 253 | 255 | } |
@@ -290,7 +292,7 @@ discard block |
||
| 290 | 292 | } |
| 291 | 293 | |
| 292 | 294 | public function getPointsByYear($year) |
| 293 | - { |
|
| 295 | + { |
|
| 294 | 296 | $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get(); |
| 295 | 297 | foreach ($teamMatches as $key=>$teamMatch) { |
| 296 | 298 | $pointsData[$key]['name'] = $teamMatch['team']['name']; |