Completed
Push — master ( d565f6...12549b )
by Michael
02:45
created
app/controllers/TeamMatchesController.php 1 patch
Braces   +36 added lines, -34 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
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,20 +75,20 @@  discard block
 block discarded – undo
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
 
88 88
 
89 89
         // Separate two teams
90 90
 
91
-        foreach($matchUp as $key=>$item){
91
+        foreach($matchUp as $key=>$item) {
92 92
             $teamIds[$key] = $item['team'];
93 93
         }
94 94
         sort($teamIds);
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
         $team1 = array();
100 100
         $team2 = array();
101 101
 
102
-        foreach($matchUp as $key=>$match){
103
-            if($match['team'] ==$team1Id ){
102
+        foreach($matchUp as $key=>$match) {
103
+            if($match['team'] ==$team1Id ) {
104 104
                 $team1[] = $matchUp[$key];
105 105
             } else {
106 106
                 $team2[] = $matchUp[$key];
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 
110 110
 
111 111
         $team1Name = Team::select('name')->where('id', '=', $team1Id)->get()->toArray();
112
-        foreach($matchUp as $key=>$match){
113
-            if($match['team'] == $team1[0]['team']){
112
+        foreach($matchUp as $key=>$match) {
113
+            if($match['team'] == $team1[0]['team']) {
114 114
                 $team1[] = $match;
115 115
                 unset($matchUp[$key]);
116 116
             }
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
             $team1Bonus = null;
135 135
             $team2Bonus = null;
136 136
 
137
-            if($team1Scores[8] != null && $team2Scores[8] != null){
138
-                if($team1Points > $team2Points){
137
+            if($team1Scores[8] != null && $team2Scores[8] != null) {
138
+                if($team1Points > $team2Points) {
139 139
                     $team1Points = $team1Points + 1;
140 140
                     $team1Bonus = 1;
141 141
                 }
142
-                if($team2Points > $team1Points){
142
+                if($team2Points > $team1Points) {
143 143
                     $team2Points = $team2Points + 1;
144 144
                     $team2Bonus = 1;
145 145
                 }
146
-                if($team1Points == $team2Points){
146
+                if($team1Points == $team2Points) {
147 147
                     $team1Points = $team1Points + .5;
148 148
                     $team1Bonus = .5;
149 149
                     $team2Points = $team2Points + .5;
@@ -159,16 +159,16 @@  discard block
 block discarded – undo
159 159
         //Need to determine if same amount of scores are in both
160 160
         // If not then do not return
161 161
 
162
-        foreach($team1Scores as $key=>$teamScore){
163
-            if($teamScore <= 0){
162
+        foreach($team1Scores as $key=>$teamScore) {
163
+            if($teamScore <= 0) {
164 164
                 $team1Scores[$key] = '';
165 165
             }
166 166
         }
167 167
         $team1Net = array_sum($team1Scores);
168 168
 
169 169
 
170
-        foreach($team2Scores as $key=>$teamScore){
171
-            if($teamScore <= 0){
170
+        foreach($team2Scores as $key=>$teamScore) {
171
+            if($teamScore <= 0) {
172 172
                 $team2Scores[$key] = '';
173 173
             }
174 174
         }
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 
214 214
     private function getTeamNetScore($team, $holesData)
215 215
     {
216
-        foreach($team as $key=>$item){
216
+        foreach($team as $key=>$item) {
217 217
             // Create holes array for NET
218 218
             $holes = array();
219 219
             $i = 1;
220
-            foreach($holesData as $key=>$holeData){
220
+            foreach($holesData as $key=>$holeData) {
221 221
                 $holes[$i] = $holeData->handicap;
222 222
                 $i++;
223 223
             }
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
                 9 => 0
236 236
             ];
237 237
             //Create array of strokes
238
-            for($counter = $item['matchHandicap']; $counter > 0; $counter--){
239
-                if($counter > 9){
238
+            for($counter = $item['matchHandicap']; $counter > 0; $counter--) {
239
+                if($counter > 9) {
240 240
                     $newCounter = $counter - 9;
241 241
                     while($newCounter > 0) {
242 242
                         $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
             // Plus handicaps don't hit previous loop so need its own
250 250
             //Plus handicap logic
251 251
 
252
-            foreach($strokeArray as $strokeKey=>$stroke){
252
+            foreach($strokeArray as $strokeKey=>$stroke) {
253 253
                 $holeKey = array_search($strokeKey,$holes);
254 254
                 $holes[$holeKey] = $stroke;
255 255
             }
@@ -258,19 +258,21 @@  discard block
 block discarded – undo
258 258
             //get array of holescores
259 259
 
260 260
             $holeScores = $item['holescores'];
261
-            foreach($holeScores as $key=>$holeScore){
261
+            foreach($holeScores as $key=>$holeScore) {
262 262
                 //check if new score is less PlayerScores
263
-                if(isset($teamScores[$key])){ // 2nd time in for hole
263
+                if(isset($teamScores[$key])) {
264
+// 2nd time in for hole
264 265
 
265 266
                     //set temp handi score
266 267
                     $tempScore = $holeScore['score'] - $holes[$key+1];
267
-                    if($teamScores[$key] >= $tempScore){
268
+                    if($teamScores[$key] >= $tempScore) {
268 269
                         $teamScores[$key] = $holeScore['score'] - $holes[$key+1];
269 270
                     }
270
-                } else{ // first time in for hole
271
-                    if($holeScore['score'] != null){
271
+                } else {
272
+// first time in for hole
273
+                    if($holeScore['score'] != null) {
272 274
                         $teamScores[$key] = $holeScore['score'] - $holes[$key+1];
273
-                    } else{
275
+                    } else {
274 276
                         $teamScores[$key] = null;
275 277
                     }
276 278
                 }
@@ -285,12 +287,12 @@  discard block
 block discarded – undo
285 287
         $points = 0;
286 288
         $teamTotalPoints = 0;
287 289
         $opponentTotalPoints = 0;
288
-        foreach ($team as $key=>$score){
289
-            if($score != null){
290
-                if($score < $opponent[$key]){
290
+        foreach ($team as $key=>$score) {
291
+            if($score != null) {
292
+                if($score < $opponent[$key]) {
291 293
                     $points++;
292 294
                 }
293
-                if($score == $opponent[$key]){
295
+                if($score == $opponent[$key]) {
294 296
                     $points = $points + .5;
295 297
                 }
296 298
             }
@@ -336,9 +338,9 @@  discard block
 block discarded – undo
336 338
 	}
337 339
 
338 340
 	public function getPointsByYear($year)
339
-    {
341
+	{
340 342
         $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
341
-        foreach($teamMatches as $key=>$teamMatch){
343
+        foreach($teamMatches as $key=>$teamMatch) {
342 344
             $pointsData[$key]['name'] = $teamMatch['team']['name'];
343 345
             $pointsData[$key]['points'] =  Teammatch::select('team_id','pointsWon')
344 346
                 ->where('team_id', '=', $teamMatch->team_id)
Please login to merge, or discard this patch.