Completed
Push — master ( d565f6...12549b )
by Michael
02:45
created
app/controllers/TeamMatchesController.php 1 patch
Spacing   +41 added lines, -41 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
-            $matchUp[$key]['matchHandicap'] = round($groupPlayer->pivot->handicap ,0);
69
-            foreach ($groupPlayer->round as $round){
68
+            $matchUp[$key]['matchHandicap'] = round($groupPlayer->pivot->handicap, 0);
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,10 +235,10 @@  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
-                    while($newCounter > 0) {
241
+                    while ($newCounter > 0) {
242 242
                         $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
243 243
                         $counter--;
244 244
                         $newCounter--;
@@ -249,8 +249,8 @@  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){
253
-                $holeKey = array_search($strokeKey,$holes);
252
+            foreach ($strokeArray as $strokeKey=>$stroke) {
253
+                $holeKey = array_search($strokeKey, $holes);
254 254
                 $holes[$holeKey] = $stroke;
255 255
             }
256 256
 
@@ -258,19 +258,19 @@  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])) { // 2nd time in for hole
264 264
 
265 265
                     //set temp handi score
266
-                    $tempScore = $holeScore['score'] - $holes[$key+1];
267
-                    if($teamScores[$key] >= $tempScore){
268
-                        $teamScores[$key] = $holeScore['score'] - $holes[$key+1];
266
+                    $tempScore = $holeScore['score'] - $holes[$key + 1];
267
+                    if ($teamScores[$key] >= $tempScore) {
268
+                        $teamScores[$key] = $holeScore['score'] - $holes[$key + 1];
269 269
                     }
270
-                } else{ // first time in for hole
271
-                    if($holeScore['score'] != null){
272
-                        $teamScores[$key] = $holeScore['score'] - $holes[$key+1];
273
-                    } else{
270
+                } else { // first time in for hole
271
+                    if ($holeScore['score'] != null) {
272
+                        $teamScores[$key] = $holeScore['score'] - $holes[$key + 1];
273
+                    } else {
274 274
                         $teamScores[$key] = null;
275 275
                     }
276 276
                 }
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
         $points = 0;
286 286
         $teamTotalPoints = 0;
287 287
         $opponentTotalPoints = 0;
288
-        foreach ($team as $key=>$score){
289
-            if($score != null){
290
-                if($score < $opponent[$key]){
288
+        foreach ($team as $key=>$score) {
289
+            if ($score != null) {
290
+                if ($score < $opponent[$key]) {
291 291
                     $points++;
292 292
                 }
293
-                if($score == $opponent[$key]){
293
+                if ($score == $opponent[$key]) {
294 294
                     $points = $points + .5;
295 295
                 }
296 296
             }
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
 
338 338
 	public function getPointsByYear($year)
339 339
     {
340
-        $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
341
-        foreach($teamMatches as $key=>$teamMatch){
340
+        $teamMatches = Teammatch::select('team_id', 'pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
341
+        foreach ($teamMatches as $key=>$teamMatch) {
342 342
             $pointsData[$key]['name'] = $teamMatch['team']['name'];
343
-            $pointsData[$key]['points'] =  Teammatch::select('team_id','pointsWon')
343
+            $pointsData[$key]['points'] = Teammatch::select('team_id', 'pointsWon')
344 344
                 ->where('team_id', '=', $teamMatch->team_id)
345 345
                 ->whereYear('created_at', '=', $year)
346 346
                 ->with('team')
Please login to merge, or discard this patch.