Completed
Push — master ( c2b49a...8bd31d )
by Michael
02:56
created
app/controllers/TeamMatchesController.php 3 patches
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
 
7 7
 class TeamMatchesController extends \BaseController {
8 8
 
9
-    public function __construct(MatchService $match, MatchRoundRepository $matchRoundRepo, TeamMatchesRepository $teamMatchesRepository)
10
-    {
11
-        $this->match = $match;
12
-        $this->matchRoundRepo = $matchRoundRepo;
13
-        $this->teamMatchesRepo = $teamMatchesRepository;
14
-    }
15
-
16
-    /**
9
+	public function __construct(MatchService $match, MatchRoundRepository $matchRoundRepo, TeamMatchesRepository $teamMatchesRepository)
10
+	{
11
+		$this->match = $match;
12
+		$this->matchRoundRepo = $matchRoundRepo;
13
+		$this->teamMatchesRepo = $teamMatchesRepository;
14
+	}
15
+
16
+	/**
17 17
 	 * Display a listing of the resource.
18 18
 	 *
19 19
 	 * @return Response
@@ -56,203 +56,203 @@  discard block
 block discarded – undo
56 56
 	{
57 57
 
58 58
 
59
-        $group = Input::get('group');
60
-
61
-
62
-        $groupPlayers = $this->matchRoundRepo->matchGroup($id, $group);
63
-
64
-        //Create Player data
65
-        $matchUp = array();
66
-        foreach($groupPlayers as $key=>$groupPlayer){
67
-            $matchUp[$key]['player'] = $groupPlayer->pivot->player_id;
68
-            $matchUp[$key]['matchHandicap'] = round($groupPlayer->pivot->handicap ,0);
69
-            foreach ($groupPlayer->round as $round){
70
-                $matchUp[$key]['team'] = $round->team_id;
71
-                $matchUp[$key]['course'] = $round->course_id;
72
-                $matchUp[$key]['holescores'] = $round->holescores;
73
-            }
74
-
75
-        }
76
-
77
-        // Change lowest handicap to ZERO and change others to reflect it
78
-            foreach($matchUp as $key=>$match){
79
-                $matchHandicaps[] = $match['matchHandicap'];
80
-            }
81
-            $lowestMatchHandicap = min($matchHandicaps);
82
-            //handicap change
83
-            $handicapChange = $lowestMatchHandicap * -1;
84
-            foreach($matchUp as $key=>$match){
85
-                $matchUp[$key]['matchHandicap'] = $match['matchHandicap'] + $handicapChange;
86
-            }
87
-
88
-        // Separate two teams
89
-            $team1 = array(array_shift ($matchUp));
90
-            $team1Id = $team1[0]['team'];
91
-            $team1Name = Team::select('name')->where('id', '=', $team1Id)->get()->toArray();
92
-            foreach($matchUp as $key=>$match){
93
-                if($match['team'] == $team1[0]['team']){
94
-                    $team1[] = $match;
95
-                    unset($matchUp[$key]);
96
-                }
97
-            }
98
-            $team2 = $matchUp;
99
-            $team2Id = $team2[1]['team'];
100
-            $team2Name = Team::select('name')->where('id', '=', $team2Id)->get()->toArray();
101
-
102
-            $holesData = Hole::select('handicap')->where('course_id', '=', $team1[0]['course'])->get();
103
-
104
-            $team1Scores = $this->getTeamNetScore($team1, $holesData);
105
-            $team2Scores = $this->getTeamNetScore($team2, $holesData);
106
-
107
-            $team1Points = $this->calculatePoints($team1Scores, $team2Scores);
108
-            $team2Points = $this->calculatePoints($team2Scores, $team1Scores);
109
-
110
-            //Save Points in Teammatches
111
-            Teammatch::where('match_id', '=', $id)->where('team_id', '=', $team1Id)->update(array('pointsWon' => $team1Points));
112
-            Teammatch::where('match_id', '=', $id)->where('team_id', '=', $team2Id)->update(array('pointsWon' => $team2Points));
113
-
114
-
115
-        //Need to determine if same amount of scores are in both
116
-        // If not then do not return
117
-
118
-            foreach($team1Scores as $key=>$teamScore){
119
-                if($teamScore <= 0){
120
-                    $team1Scores[$key] = '';
121
-                }
122
-            }
123
-
124
-        foreach($team2Scores as $key=>$teamScore){
125
-            if($teamScore <= 0){
126
-                $team2Scores[$key] = '';
127
-            }
128
-        }
129
-
130
-        $team[0] = [
131
-            "team" =>  $team1Name[0]['name'],
132
-            "hole1" => $team1Scores[0],
133
-            "hole2" => $team1Scores[1],
134
-            "hole3" => $team1Scores[2],
135
-            "hole4" => $team1Scores[3],
136
-            "hole5" => $team1Scores[4],
137
-            "hole6" => $team1Scores[5],
138
-            "hole7" => $team1Scores[6],
139
-            "hole8" => $team1Scores[7],
140
-            "hole9" => $team1Scores[8],
141
-            "points" =>$team1Points
142
-        ];
143
-
144
-        $team[1] = [
145
-            "team" =>  $team2Name[0]['name'],
146
-            "hole1" => $team2Scores[0],
147
-            "hole2" => $team2Scores[1],
148
-            "hole3" => $team2Scores[2],
149
-            "hole4" => $team2Scores[3],
150
-            "hole5" => $team2Scores[4],
151
-            "hole6" => $team2Scores[5],
152
-            "hole7" => $team2Scores[6],
153
-            "hole8" => $team2Scores[7],
154
-            "hole9" => $team2Scores[8],
155
-            "points" => $team2Points
156
-        ];
157
-
158
-        $data['data'] = $team;
159
-        return $data;
59
+		$group = Input::get('group');
60
+
61
+
62
+		$groupPlayers = $this->matchRoundRepo->matchGroup($id, $group);
63
+
64
+		//Create Player data
65
+		$matchUp = array();
66
+		foreach($groupPlayers as $key=>$groupPlayer){
67
+			$matchUp[$key]['player'] = $groupPlayer->pivot->player_id;
68
+			$matchUp[$key]['matchHandicap'] = round($groupPlayer->pivot->handicap ,0);
69
+			foreach ($groupPlayer->round as $round){
70
+				$matchUp[$key]['team'] = $round->team_id;
71
+				$matchUp[$key]['course'] = $round->course_id;
72
+				$matchUp[$key]['holescores'] = $round->holescores;
73
+			}
74
+
75
+		}
76
+
77
+		// Change lowest handicap to ZERO and change others to reflect it
78
+			foreach($matchUp as $key=>$match){
79
+				$matchHandicaps[] = $match['matchHandicap'];
80
+			}
81
+			$lowestMatchHandicap = min($matchHandicaps);
82
+			//handicap change
83
+			$handicapChange = $lowestMatchHandicap * -1;
84
+			foreach($matchUp as $key=>$match){
85
+				$matchUp[$key]['matchHandicap'] = $match['matchHandicap'] + $handicapChange;
86
+			}
87
+
88
+		// Separate two teams
89
+			$team1 = array(array_shift ($matchUp));
90
+			$team1Id = $team1[0]['team'];
91
+			$team1Name = Team::select('name')->where('id', '=', $team1Id)->get()->toArray();
92
+			foreach($matchUp as $key=>$match){
93
+				if($match['team'] == $team1[0]['team']){
94
+					$team1[] = $match;
95
+					unset($matchUp[$key]);
96
+				}
97
+			}
98
+			$team2 = $matchUp;
99
+			$team2Id = $team2[1]['team'];
100
+			$team2Name = Team::select('name')->where('id', '=', $team2Id)->get()->toArray();
101
+
102
+			$holesData = Hole::select('handicap')->where('course_id', '=', $team1[0]['course'])->get();
103
+
104
+			$team1Scores = $this->getTeamNetScore($team1, $holesData);
105
+			$team2Scores = $this->getTeamNetScore($team2, $holesData);
106
+
107
+			$team1Points = $this->calculatePoints($team1Scores, $team2Scores);
108
+			$team2Points = $this->calculatePoints($team2Scores, $team1Scores);
109
+
110
+			//Save Points in Teammatches
111
+			Teammatch::where('match_id', '=', $id)->where('team_id', '=', $team1Id)->update(array('pointsWon' => $team1Points));
112
+			Teammatch::where('match_id', '=', $id)->where('team_id', '=', $team2Id)->update(array('pointsWon' => $team2Points));
113
+
114
+
115
+		//Need to determine if same amount of scores are in both
116
+		// If not then do not return
117
+
118
+			foreach($team1Scores as $key=>$teamScore){
119
+				if($teamScore <= 0){
120
+					$team1Scores[$key] = '';
121
+				}
122
+			}
123
+
124
+		foreach($team2Scores as $key=>$teamScore){
125
+			if($teamScore <= 0){
126
+				$team2Scores[$key] = '';
127
+			}
128
+		}
129
+
130
+		$team[0] = [
131
+			"team" =>  $team1Name[0]['name'],
132
+			"hole1" => $team1Scores[0],
133
+			"hole2" => $team1Scores[1],
134
+			"hole3" => $team1Scores[2],
135
+			"hole4" => $team1Scores[3],
136
+			"hole5" => $team1Scores[4],
137
+			"hole6" => $team1Scores[5],
138
+			"hole7" => $team1Scores[6],
139
+			"hole8" => $team1Scores[7],
140
+			"hole9" => $team1Scores[8],
141
+			"points" =>$team1Points
142
+		];
143
+
144
+		$team[1] = [
145
+			"team" =>  $team2Name[0]['name'],
146
+			"hole1" => $team2Scores[0],
147
+			"hole2" => $team2Scores[1],
148
+			"hole3" => $team2Scores[2],
149
+			"hole4" => $team2Scores[3],
150
+			"hole5" => $team2Scores[4],
151
+			"hole6" => $team2Scores[5],
152
+			"hole7" => $team2Scores[6],
153
+			"hole8" => $team2Scores[7],
154
+			"hole9" => $team2Scores[8],
155
+			"points" => $team2Points
156
+		];
157
+
158
+		$data['data'] = $team;
159
+		return $data;
160 160
 	}
161 161
 
162
-    private function getTeamNetScore($team, $holesData)
163
-    {
164
-        foreach($team as $key=>$item){
165
-            // Create holes array for NET
166
-            $holes = array();
167
-            $i = 1;
168
-            foreach($holesData as $key=>$holeData){
169
-                $holes[$i] = $holeData->handicap;
170
-                $i++;
171
-            }
172
-
173
-            // Create stroke array - how many to take away from score
174
-            $strokeArray = [
175
-                1 => 0,
176
-                2 => 0,
177
-                3 => 0,
178
-                4 => 0,
179
-                5 => 0,
180
-                6 => 0,
181
-                7 => 0,
182
-                8 => 0,
183
-                9 => 0
184
-            ];
185
-            //Create array of strokes
186
-            for($counter = $item['matchHandicap']; $counter > 0; $counter--){
187
-                if($counter > 9){
188
-                    $newCounter = $counter - 9;
189
-                    while($newCounter > 0) {
190
-                        $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
191
-                        $counter--;
192
-                        $newCounter--;
193
-                    }
194
-                }
195
-                $strokeArray[$counter] = $strokeArray[$counter] + 1;
196
-            }
197
-            // Plus handicaps don't hit previous loop so need its own
198
-            //Plus handicap logic
199
-
200
-            foreach($strokeArray as $strokeKey=>$stroke){
201
-                $holeKey = array_search($strokeKey,$holes);
202
-                $holes[$holeKey] = $stroke;
203
-            }
204
-
205
-            ///now have array of strokes to subtract
206
-            //get array of holescores
207
-
208
-            $holeScores = $item['holescores'];
209
-            foreach($holeScores as $key=>$holeScore){
210
-                //check if new score is less PlayerScores
211
-                if(isset($playerScores[$key])){ // 2nd time in for hole
212
-                    if($playerScores[$key] >= $holeScore['score']){
213
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
214
-                    }
215
-                } else{ // first time in for hole
216
-                    if($holeScore['score'] != null){
217
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
218
-                    } else{
219
-                        $playerScores[$key] = null;
220
-                    }
221
-                }
222
-            }
223
-
224
-        }
225
-        return $playerScores;
226
-    }
227
-
228
-    private function calculatePoints($team, $opponent)
229
-    {
230
-        $points = 0;
231
-        $teamTotalPoints = 0;
232
-        $opponentTotalPoints = 0;
233
-        foreach ($team as $key=>$score){
234
-            if($score != null){
235
-                if($score < $opponent[$key]){
236
-                    $points++;
237
-                }
238
-                if($score == $opponent[$key]){
239
-                    $points = $points + .5;
240
-                }
241
-            }
242
-            $teamTotalPoints = $teamTotalPoints + $points;
243
-            $opponentTotalPoints = $opponentTotalPoints + $points;
244
-        }
245
-        // Bonus point logic
246
-        if($team[8] != null && $opponent[8] != null){
247
-            if($teamTotalPoints > $opponentTotalPoints){
248
-                $points = $points + 1;
249
-            }
250
-            if($teamTotalPoints == $opponentTotalPoints){
251
-                $points = $points + .5;
252
-            }
253
-        }
254
-        return $points;
255
-    }
162
+	private function getTeamNetScore($team, $holesData)
163
+	{
164
+		foreach($team as $key=>$item){
165
+			// Create holes array for NET
166
+			$holes = array();
167
+			$i = 1;
168
+			foreach($holesData as $key=>$holeData){
169
+				$holes[$i] = $holeData->handicap;
170
+				$i++;
171
+			}
172
+
173
+			// Create stroke array - how many to take away from score
174
+			$strokeArray = [
175
+				1 => 0,
176
+				2 => 0,
177
+				3 => 0,
178
+				4 => 0,
179
+				5 => 0,
180
+				6 => 0,
181
+				7 => 0,
182
+				8 => 0,
183
+				9 => 0
184
+			];
185
+			//Create array of strokes
186
+			for($counter = $item['matchHandicap']; $counter > 0; $counter--){
187
+				if($counter > 9){
188
+					$newCounter = $counter - 9;
189
+					while($newCounter > 0) {
190
+						$strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
191
+						$counter--;
192
+						$newCounter--;
193
+					}
194
+				}
195
+				$strokeArray[$counter] = $strokeArray[$counter] + 1;
196
+			}
197
+			// Plus handicaps don't hit previous loop so need its own
198
+			//Plus handicap logic
199
+
200
+			foreach($strokeArray as $strokeKey=>$stroke){
201
+				$holeKey = array_search($strokeKey,$holes);
202
+				$holes[$holeKey] = $stroke;
203
+			}
204
+
205
+			///now have array of strokes to subtract
206
+			//get array of holescores
207
+
208
+			$holeScores = $item['holescores'];
209
+			foreach($holeScores as $key=>$holeScore){
210
+				//check if new score is less PlayerScores
211
+				if(isset($playerScores[$key])){ // 2nd time in for hole
212
+					if($playerScores[$key] >= $holeScore['score']){
213
+						$playerScores[$key] = $holeScore['score'] - $holes[$key+1];
214
+					}
215
+				} else{ // first time in for hole
216
+					if($holeScore['score'] != null){
217
+						$playerScores[$key] = $holeScore['score'] - $holes[$key+1];
218
+					} else{
219
+						$playerScores[$key] = null;
220
+					}
221
+				}
222
+			}
223
+
224
+		}
225
+		return $playerScores;
226
+	}
227
+
228
+	private function calculatePoints($team, $opponent)
229
+	{
230
+		$points = 0;
231
+		$teamTotalPoints = 0;
232
+		$opponentTotalPoints = 0;
233
+		foreach ($team as $key=>$score){
234
+			if($score != null){
235
+				if($score < $opponent[$key]){
236
+					$points++;
237
+				}
238
+				if($score == $opponent[$key]){
239
+					$points = $points + .5;
240
+				}
241
+			}
242
+			$teamTotalPoints = $teamTotalPoints + $points;
243
+			$opponentTotalPoints = $opponentTotalPoints + $points;
244
+		}
245
+		// Bonus point logic
246
+		if($team[8] != null && $opponent[8] != null){
247
+			if($teamTotalPoints > $opponentTotalPoints){
248
+				$points = $points + 1;
249
+			}
250
+			if($teamTotalPoints == $opponentTotalPoints){
251
+				$points = $points + .5;
252
+			}
253
+		}
254
+		return $points;
255
+	}
256 256
 
257 257
 	/**
258 258
 	 * Show the form for editing the specified resource.
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
 	}
291 291
 
292 292
 	public function getPointsByYear($year)
293
-    {
294
-        $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
295
-        foreach ($teamMatches as $key=>$teamMatch) {
296
-            $pointsData[$key]['name'] = $teamMatch['team']['name'];
297
-            $pointsData[$key]['points'] = $teamMatch['pointsWon'];
298
-        }
299
-        $data['data'] = $pointsData;
300
-        return $data;
301
-    }
293
+	{
294
+		$teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
295
+		foreach ($teamMatches as $key=>$teamMatch) {
296
+			$pointsData[$key]['name'] = $teamMatch['team']['name'];
297
+			$pointsData[$key]['points'] = $teamMatch['pointsWon'];
298
+		}
299
+		$data['data'] = $pointsData;
300
+		return $data;
301
+	}
302 302
 
303 303
 
304 304
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 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
                 }
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,10 +183,10 @@  discard block
 block discarded – undo
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
-                    while($newCounter > 0) {
189
+                    while ($newCounter > 0) {
190 190
                         $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
191 191
                         $counter--;
192 192
                         $newCounter--;
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
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){
201
-                $holeKey = array_search($strokeKey,$holes);
200
+            foreach ($strokeArray as $strokeKey=>$stroke) {
201
+                $holeKey = array_search($strokeKey, $holes);
202 202
                 $holes[$holeKey] = $stroke;
203 203
             }
204 204
 
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
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']){
213
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
211
+                if (isset($playerScores[$key])) { // 2nd time in for hole
212
+                    if ($playerScores[$key] >= $holeScore['score']) {
213
+                        $playerScores[$key] = $holeScore['score'] - $holes[$key + 1];
214 214
                     }
215
-                } else{ // first time in for hole
216
-                    if($holeScore['score'] != null){
217
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
218
-                    } else{
215
+                } else { // first time in for hole
216
+                    if ($holeScore['score'] != null) {
217
+                        $playerScores[$key] = $holeScore['score'] - $holes[$key + 1];
218
+                    } else {
219 219
                         $playerScores[$key] = null;
220 220
                     }
221 221
                 }
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
         $points = 0;
231 231
         $teamTotalPoints = 0;
232 232
         $opponentTotalPoints = 0;
233
-        foreach ($team as $key=>$score){
234
-            if($score != null){
235
-                if($score < $opponent[$key]){
233
+        foreach ($team as $key=>$score) {
234
+            if ($score != null) {
235
+                if ($score < $opponent[$key]) {
236 236
                     $points++;
237 237
                 }
238
-                if($score == $opponent[$key]){
238
+                if ($score == $opponent[$key]) {
239 239
                     $points = $points + .5;
240 240
                 }
241 241
             }
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
             $opponentTotalPoints = $opponentTotalPoints + $points;
244 244
         }
245 245
         // Bonus point logic
246
-        if($team[8] != null && $opponent[8] != null){
247
-            if($teamTotalPoints > $opponentTotalPoints){
246
+        if ($team[8] != null && $opponent[8] != null) {
247
+            if ($teamTotalPoints > $opponentTotalPoints) {
248 248
                 $points = $points + 1;
249 249
             }
250
-            if($teamTotalPoints == $opponentTotalPoints){
250
+            if ($teamTotalPoints == $opponentTotalPoints) {
251 251
                 $points = $points + .5;
252 252
             }
253 253
         }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
 	public function getPointsByYear($year)
293 293
     {
294
-        $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
294
+        $teamMatches = Teammatch::select('team_id', 'pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
295 295
         foreach ($teamMatches as $key=>$teamMatch) {
296 296
             $pointsData[$key]['name'] = $teamMatch['team']['name'];
297 297
             $pointsData[$key]['points'] = $teamMatch['pointsWon'];
Please login to merge, or discard this patch.
Braces   +31 added lines, -29 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,13 +75,13 @@  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
 
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'];
Please login to merge, or discard this patch.