Completed
Push — master ( eac09e...d565f6 )
by Michael
03:18
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
             }
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
             // Bonus point logic
132 132
             // Occurs after 9th hole score is added to both teams
133 133
 
134
-            if($team1Scores[8] != null && $team2Scores[8] != null){
135
-                if($team1Points > $team2Points){
134
+            if ($team1Scores[8] != null && $team2Scores[8] != null) {
135
+                if ($team1Points > $team2Points) {
136 136
                     $team1Points = $team1Points + 1;
137 137
                 }
138
-                if($team2Points > $team1Points){
138
+                if ($team2Points > $team1Points) {
139 139
                     $team2Points = $team2Points + 1;
140 140
                 }
141
-                if($team1Points == $team2Points){
141
+                if ($team1Points == $team2Points) {
142 142
                     $team1Points = $team1Points + .5;
143 143
                     $team2Points = $team2Points + .5;
144 144
                 }
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
         //Need to determine if same amount of scores are in both
153 153
         // If not then do not return
154 154
 
155
-            foreach($team1Scores as $key=>$teamScore){
156
-                if($teamScore <= 0){
155
+            foreach ($team1Scores as $key=>$teamScore) {
156
+                if ($teamScore <= 0) {
157 157
                     $team1Scores[$key] = '';
158 158
                 }
159 159
             }
160 160
 
161
-        foreach($team2Scores as $key=>$teamScore){
162
-            if($teamScore <= 0){
161
+        foreach ($team2Scores as $key=>$teamScore) {
162
+            if ($teamScore <= 0) {
163 163
                 $team2Scores[$key] = '';
164 164
             }
165 165
         }
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
 
199 199
     private function getTeamNetScore($team, $holesData)
200 200
     {
201
-        foreach($team as $key=>$item){
201
+        foreach ($team as $key=>$item) {
202 202
             // Create holes array for NET
203 203
             $holes = array();
204 204
             $i = 1;
205
-            foreach($holesData as $key=>$holeData){
205
+            foreach ($holesData as $key=>$holeData) {
206 206
                 $holes[$i] = $holeData->handicap;
207 207
                 $i++;
208 208
             }
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
                 9 => 0
221 221
             ];
222 222
             //Create array of strokes
223
-            for($counter = $item['matchHandicap']; $counter > 0; $counter--){
224
-                if($counter > 9){
223
+            for ($counter = $item['matchHandicap']; $counter > 0; $counter--) {
224
+                if ($counter > 9) {
225 225
                     $newCounter = $counter - 9;
226
-                    while($newCounter > 0) {
226
+                    while ($newCounter > 0) {
227 227
                         $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
228 228
                         $counter--;
229 229
                         $newCounter--;
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
             // Plus handicaps don't hit previous loop so need its own
235 235
             //Plus handicap logic
236 236
 
237
-            foreach($strokeArray as $strokeKey=>$stroke){
238
-                $holeKey = array_search($strokeKey,$holes);
237
+            foreach ($strokeArray as $strokeKey=>$stroke) {
238
+                $holeKey = array_search($strokeKey, $holes);
239 239
                 $holes[$holeKey] = $stroke;
240 240
             }
241 241
 
@@ -243,19 +243,19 @@  discard block
 block discarded – undo
243 243
             //get array of holescores
244 244
 
245 245
             $holeScores = $item['holescores'];
246
-            foreach($holeScores as $key=>$holeScore){
246
+            foreach ($holeScores as $key=>$holeScore) {
247 247
                 //check if new score is less PlayerScores
248
-                if(isset($teamScores[$key])){ // 2nd time in for hole
248
+                if (isset($teamScores[$key])) { // 2nd time in for hole
249 249
 
250 250
                     //set temp handi score
251
-                    $tempScore = $holeScore['score'] - $holes[$key+1];
252
-                    if($teamScores[$key] >= $tempScore){
253
-                        $teamScores[$key] = $holeScore['score'] - $holes[$key+1];
251
+                    $tempScore = $holeScore['score'] - $holes[$key + 1];
252
+                    if ($teamScores[$key] >= $tempScore) {
253
+                        $teamScores[$key] = $holeScore['score'] - $holes[$key + 1];
254 254
                     }
255
-                } else{ // first time in for hole
256
-                    if($holeScore['score'] != null){
257
-                        $teamScores[$key] = $holeScore['score'] - $holes[$key+1];
258
-                    } else{
255
+                } else { // first time in for hole
256
+                    if ($holeScore['score'] != null) {
257
+                        $teamScores[$key] = $holeScore['score'] - $holes[$key + 1];
258
+                    } else {
259 259
                         $teamScores[$key] = null;
260 260
                     }
261 261
                 }
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
         $points = 0;
271 271
         $teamTotalPoints = 0;
272 272
         $opponentTotalPoints = 0;
273
-        foreach ($team as $key=>$score){
274
-            if($score != null){
275
-                if($score < $opponent[$key]){
273
+        foreach ($team as $key=>$score) {
274
+            if ($score != null) {
275
+                if ($score < $opponent[$key]) {
276 276
                     $points++;
277 277
                 }
278
-                if($score == $opponent[$key]){
278
+                if ($score == $opponent[$key]) {
279 279
                     $points = $points + .5;
280 280
                 }
281 281
             }
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
 
323 323
 	public function getPointsByYear($year)
324 324
     {
325
-        $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
326
-        foreach($teamMatches as $key=>$teamMatch){
325
+        $teamMatches = Teammatch::select('team_id', 'pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
326
+        foreach ($teamMatches as $key=>$teamMatch) {
327 327
             $pointsData[$key]['name'] = $teamMatch['team']['name'];
328
-            $pointsData[$key]['points'] =  Teammatch::select('team_id','pointsWon')
328
+            $pointsData[$key]['points'] = Teammatch::select('team_id', 'pointsWon')
329 329
                 ->where('team_id', '=', $teamMatch->team_id)
330 330
                 ->whereYear('created_at', '=', $year)
331 331
                 ->with('team')
Please login to merge, or discard this patch.