Completed
Push — master ( 8bd31d...cb05a7 )
by Michael
02:50
created
app/controllers/TeamMatchesController.php 1 patch
Spacing   +36 added lines, -36 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,22 +75,22 @@  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
         // Separate two teams
89
-            $team1 = array(array_shift ($matchUp));
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
                 }
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
             // Bonus point logic
111 111
             // Occurs after 9th hole score is added to both teams
112 112
 
113
-            if($team1Scores[8] != null && $team2Scores[8] != null){
114
-                if($team1Points > $team2Points){
113
+            if ($team1Scores[8] != null && $team2Scores[8] != null) {
114
+                if ($team1Points > $team2Points) {
115 115
                     $team1Points = $team1Points + 1;
116 116
                 }
117
-                if($team2Points > $team1Points){
117
+                if ($team2Points > $team1Points) {
118 118
                     $team2Points = $team2Points + 1;
119 119
                 }
120
-                if($team1Points == $team2Points){
120
+                if ($team1Points == $team2Points) {
121 121
                     $team1Points = $team1Points + .5;
122 122
                     $team2Points = $team2Points + .5;
123 123
                 }
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
         //Need to determine if same amount of scores are in both
132 132
         // If not then do not return
133 133
 
134
-            foreach($team1Scores as $key=>$teamScore){
135
-                if($teamScore <= 0){
134
+            foreach ($team1Scores as $key=>$teamScore) {
135
+                if ($teamScore <= 0) {
136 136
                     $team1Scores[$key] = '';
137 137
                 }
138 138
             }
139 139
 
140
-        foreach($team2Scores as $key=>$teamScore){
141
-            if($teamScore <= 0){
140
+        foreach ($team2Scores as $key=>$teamScore) {
141
+            if ($teamScore <= 0) {
142 142
                 $team2Scores[$key] = '';
143 143
             }
144 144
         }
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 
178 178
     private function getTeamNetScore($team, $holesData)
179 179
     {
180
-        foreach($team as $key=>$item){
180
+        foreach ($team as $key=>$item) {
181 181
             // Create holes array for NET
182 182
             $holes = array();
183 183
             $i = 1;
184
-            foreach($holesData as $key=>$holeData){
184
+            foreach ($holesData as $key=>$holeData) {
185 185
                 $holes[$i] = $holeData->handicap;
186 186
                 $i++;
187 187
             }
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
                 9 => 0
200 200
             ];
201 201
             //Create array of strokes
202
-            for($counter = $item['matchHandicap']; $counter > 0; $counter--){
203
-                if($counter > 9){
202
+            for ($counter = $item['matchHandicap']; $counter > 0; $counter--) {
203
+                if ($counter > 9) {
204 204
                     $newCounter = $counter - 9;
205
-                    while($newCounter > 0) {
205
+                    while ($newCounter > 0) {
206 206
                         $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
207 207
                         $counter--;
208 208
                         $newCounter--;
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
             // Plus handicaps don't hit previous loop so need its own
214 214
             //Plus handicap logic
215 215
 
216
-            foreach($strokeArray as $strokeKey=>$stroke){
217
-                $holeKey = array_search($strokeKey,$holes);
216
+            foreach ($strokeArray as $strokeKey=>$stroke) {
217
+                $holeKey = array_search($strokeKey, $holes);
218 218
                 $holes[$holeKey] = $stroke;
219 219
             }
220 220
 
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
             //get array of holescores
223 223
 
224 224
             $holeScores = $item['holescores'];
225
-            foreach($holeScores as $key=>$holeScore){
225
+            foreach ($holeScores as $key=>$holeScore) {
226 226
                 //check if new score is less PlayerScores
227
-                if(isset($playerScores[$key])){ // 2nd time in for hole
228
-                    if($playerScores[$key] >= $holeScore['score']){
229
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
227
+                if (isset($playerScores[$key])) { // 2nd time in for hole
228
+                    if ($playerScores[$key] >= $holeScore['score']) {
229
+                        $playerScores[$key] = $holeScore['score'] - $holes[$key + 1];
230 230
                     }
231
-                } else{ // first time in for hole
232
-                    if($holeScore['score'] != null){
233
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
234
-                    } else{
231
+                } else { // first time in for hole
232
+                    if ($holeScore['score'] != null) {
233
+                        $playerScores[$key] = $holeScore['score'] - $holes[$key + 1];
234
+                    } else {
235 235
                         $playerScores[$key] = null;
236 236
                     }
237 237
                 }
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
         $points = 0;
247 247
         $teamTotalPoints = 0;
248 248
         $opponentTotalPoints = 0;
249
-        foreach ($team as $key=>$score){
250
-            if($score != null){
251
-                if($score < $opponent[$key]){
249
+        foreach ($team as $key=>$score) {
250
+            if ($score != null) {
251
+                if ($score < $opponent[$key]) {
252 252
                     $points++;
253 253
                 }
254
-                if($score == $opponent[$key]){
254
+                if ($score == $opponent[$key]) {
255 255
                     $points = $points + .5;
256 256
                 }
257 257
             }
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 
299 299
 	public function getPointsByYear($year)
300 300
     {
301
-        $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
301
+        $teamMatches = Teammatch::select('team_id', 'pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
302 302
         foreach ($teamMatches as $key=>$teamMatch) {
303 303
             $pointsData[$key]['name'] = $teamMatch['team']['name'];
304 304
             $pointsData[$key]['points'] = $teamMatch['pointsWon'];
Please login to merge, or discard this patch.