Completed
Push — master ( dd5219...8b7513 )
by Michael
04:15
created
app/library/Services/MatchService.php 4 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     /**
346 346
      * Method to get match from input Match data
347 347
      *
348
-     * @param mixed $matchdata
348
+     * @param mixed $matchid
349 349
      * @return JSON object
350 350
      */
351 351
     public function get($matchid)
@@ -356,6 +356,9 @@  discard block
 block discarded – undo
356 356
 
357 357
 
358 358
 
359
+    /**
360
+     * @param string $key
361
+     */
359 362
     private function search($array, $key, $value)
360 363
     {
361 364
         $results = array();
Please login to merge, or discard this patch.
Indentation   +349 added lines, -349 removed lines patch added patch discarded remove patch
@@ -19,354 +19,354 @@
 block discarded – undo
19 19
  */
20 20
 class MatchService
21 21
 {
22
-    // Containing our matchRepository to make all our database calls to
23
-    protected $matchRepo;
24
-
25
-    /**
26
-     * Loads our $matchRepo
27
-     *
28
-     * @param MatchRepository $matchRepo
29
-     * @return MatchService
30
-     */
31
-    public function __construct(MatchRoundRepository $matchRoundRepo,
32
-                                MatchRepository $matchRepo,
33
-                                PrizeMoney $prizeMoney,
34
-                                Player $player,
35
-                                Match $match,
36
-                                CtpRepository $ctp,
37
-                                Teammatch $teammatch,
38
-                                Dispatcher $events)
39
-    {
40
-        $this->matchRoundRepo = $matchRoundRepo;
41
-        $this->matchRepo = $matchRepo;
42
-        $this->prizeMoney = $prizeMoney;
43
-        $this->player = $player;
44
-        $this->match = $match;
45
-        $this->ctp = $ctp;
46
-        $this->teammatch = $teammatch;
47
-        $this->events = $events;
48
-    }
49
-
50
-    /**
51
-     * Method to create match from input Match data
52
-     *
53
-     * @param mixed $matchdata
54
-     * @return
55
-     */
56
-    public function create($matchdata)
57
-    {
58
-        $this->prizeMoney->setPurse($matchdata['purse']);
59
-
60
-        $matchdata['purse'] = number_format($matchdata['purse'], 2);
61
-        $matchdata['grossmoney'] = $this->prizeMoney->getlowScore();
62
-        $matchdata['netmoney'] = $this->prizeMoney->getlowScore();
63
-
64
-        //How many A and B players
65
-        $totalPlayers = 0;
66
-
67
-        $aPlayerCount = 0;
22
+	// Containing our matchRepository to make all our database calls to
23
+	protected $matchRepo;
24
+
25
+	/**
26
+	 * Loads our $matchRepo
27
+	 *
28
+	 * @param MatchRepository $matchRepo
29
+	 * @return MatchService
30
+	 */
31
+	public function __construct(MatchRoundRepository $matchRoundRepo,
32
+								MatchRepository $matchRepo,
33
+								PrizeMoney $prizeMoney,
34
+								Player $player,
35
+								Match $match,
36
+								CtpRepository $ctp,
37
+								Teammatch $teammatch,
38
+								Dispatcher $events)
39
+	{
40
+		$this->matchRoundRepo = $matchRoundRepo;
41
+		$this->matchRepo = $matchRepo;
42
+		$this->prizeMoney = $prizeMoney;
43
+		$this->player = $player;
44
+		$this->match = $match;
45
+		$this->ctp = $ctp;
46
+		$this->teammatch = $teammatch;
47
+		$this->events = $events;
48
+	}
49
+
50
+	/**
51
+	 * Method to create match from input Match data
52
+	 *
53
+	 * @param mixed $matchdata
54
+	 * @return
55
+	 */
56
+	public function create($matchdata)
57
+	{
58
+		$this->prizeMoney->setPurse($matchdata['purse']);
59
+
60
+		$matchdata['purse'] = number_format($matchdata['purse'], 2);
61
+		$matchdata['grossmoney'] = $this->prizeMoney->getlowScore();
62
+		$matchdata['netmoney'] = $this->prizeMoney->getlowScore();
63
+
64
+		//How many A and B players
65
+		$totalPlayers = 0;
66
+
67
+		$aPlayerCount = 0;
68 68
         
69
-        $bPlayerCount = 0;
70
-        foreach($matchdata['player'] as $player){
71
-            if ($player['level_id'] == '1'){
72
-                $aPlayerCount++;
73
-            }
74
-            else {
75
-                $bPlayerCount++;
76
-            }
77
-            $totalPlayers++;
78
-        }
79
-
80
-        //Calculate Skins money based on how many players in each group
81
-
82
-        $matchdata['skinsamoney'] = $this->prizeMoney->skinsGroupPot($matchdata['purse'], $totalPlayers, $aPlayerCount);
83
-        $matchdata['skinsbmoney'] = $this->prizeMoney->skinsGroupPot($matchdata['purse'], $totalPlayers, $bPlayerCount);
84
-        //check for carry over money and if there is add it to skins money
85
-        $carryOver = new CarryOver;
86
-        $carryOverMoney = $carryOver->calculate();
87
-        $matchdata['skinsamoney'] +=  $carryOverMoney[1];
88
-        $matchdata['skinsbmoney'] +=  $carryOverMoney[2];
89
-
90
-        //append current handicap and set winnings to 0 for each player
91
-        foreach ($matchdata['player'] as $key=>$player) {
92
-            //get each player's current handicap
93
-            $currentPlayer = $this->player->find($player['player_id']);
94
-            $matchdata['player'][$key]['handicap'] = $currentPlayer->handicap;
95
-            $matchdata['player'][$key]['winnings'] = 0;
96
-        }// End foreach
97
-
98
-        $matchid = $this->matchRepo->create($matchdata);
99
-        $matchdata['match_id'] = $matchid;
100
-        $this->events->fire('match.create', array($matchdata));  // MatchHandler and teamMatchHandler are listening...
101
-
102
-        // Run for team Matches
103
-        if($matchdata['matchType'] === 'team' || $matchdata['matchType'] === 'both'){
104
-
105
-            foreach ($matchdata['teamMatchUp1'] as $teamKey => $team){
106
-                $matchUp1[] = $this->search($matchdata['player'], 'team', $team);
107
-            }
108
-
109
-            //Save matchUp 1
110
-            $match1['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
111
-            $match1['team_id'] = $matchUp1[0][0]['team'];
112
-            $match1['player1'] = $matchUp1[0][0]['player_id'];
113
-            $match1['player2'] = $matchUp1[0][1]['player_id'];
114
-            $match1['opponent'] = $matchUp1[1][0]['team'];
115
-            $this->teammatch->create($match1); //save to match table
116
-
117
-            $match1['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
118
-            $match1['team_id'] = $matchUp1[1][0]['team'];
119
-            $match1['player1'] = $matchUp1[1][0]['player_id'];
120
-            $match1['player2'] = $matchUp1[1][1]['player_id'];
121
-            $match1['opponent'] = $matchUp1[0][0]['team'];
122
-            $this->teammatch->create($match1); //save to match table
123
-
124
-
125
-            foreach ($matchdata['teamMatchUp2'] as $teamKey => $team){
126
-                $matchUp2[] = $this->search($matchdata['player'], 'team', $team);
127
-            }
128
-
129
-            //Save matchUp 2
130
-            $match2['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
131
-            $match2['team_id'] = $matchUp2[0][0]['team'];
132
-            $match2['player1'] = $matchUp2[0][0]['player_id'];
133
-            $match2['player2'] = $matchUp2[0][1]['player_id'];
134
-            $match2['opponent'] = $matchUp2[1][0]['team'];
135
-            $this->teammatch->create($match2); //save to match table
136
-
137
-            $match2['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
138
-            $match2['team_id'] = $matchUp2[1][0]['team'];
139
-            $match2['player1'] = $matchUp2[1][0]['player_id'];
140
-            $match2['player2'] = $matchUp2[1][1]['player_id'];
141
-            $match2['opponent'] = $matchUp2[0][0]['team'];
142
-            $this->teammatch->create($match2); //save to match table
143
-
144
-
145
-            foreach ($matchdata['teamMatchUp3'] as $teamKey => $team){
146
-                $matchUp3[] = $this->search($matchdata['player'], 'team', $team);
147
-            }
148
-
149
-            //Save matchUp 3
150
-            $match3['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
151
-            $match3['team_id'] = $matchUp3[0][0]['team'];
152
-            $match3['player1'] = $matchUp3[0][0]['player_id'];
153
-            $match3['player2'] = $matchUp3[0][1]['player_id'];
154
-            $match3['opponent'] = $matchUp3[1][0]['team'];
155
-            $this->teammatch->create($match3); //save to match table
156
-
157
-            $match3['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
158
-            $match3['team_id'] = $matchUp3[1][0]['team'];
159
-            $match3['player1'] = $matchUp3[1][0]['player_id'];
160
-            $match3['player2'] = $matchUp3[1][1]['player_id'];
161
-            $match3['opponent'] = $matchUp3[0][0]['team'];
162
-            $this->teammatch->create($match3); //save to match table
163
-
164
-        }
165
-    }
166
-
167
-    public function finalize($matchdata)
168
-    {
169
-        // post CTP1 and CTP2
170
-        $ctp1 = array(
171
-            'match_id' => $matchdata['match'],
172
-            'player_id' => $matchdata['ctp1'],
173
-            'hole_id' => $matchdata['ctp1hole'],
174
-            'money' => $this->prizeMoney->getCtp()
175
-        );
176
-        $this->ctp->create($ctp1);
177
-        $ctp2 = array(
178
-            'match_id' => $matchdata['match'],
179
-            'player_id' => $matchdata['ctp2'],
180
-            'hole_id' => $matchdata['ctp2hole'],
181
-            'money' => $this->prizeMoney->getCtp()
182
-        );
183
-        $this->ctp->create($ctp2);
184
-
185
-        //calculate Gross winner and post to grossWinnersTable
186
-
187
-        $matchRound = $this->matchRoundRepo->getByMatch($matchdata['match']);
188
-
189
-
190
-        $lowGross = array();
191
-        foreach ($matchRound as $key => $match){
192
-            $lowGross[$match['player']->id] = $match['score'];
193
-        }
194
-        $arrayLowGross = array_keys($lowGross, min($lowGross));
195
-        foreach($arrayLowGross as $key => $lowgrossPlayer) {
196
-            $grossWinner = new Grosswinner;
197
-            $grossWinner->player_id = $lowgrossPlayer;
198
-            $grossWinner->match_id = $matchdata['match'];
199
-            $grossWinner->score = $lowGross[$lowgrossPlayer];
200
-            $grossWinner->money = $this->prizeMoney->getlowScore() / count($arrayLowGross);
201
-            $grossWinner->save();
202
-        }
203
-
204
-        //Calculate NET winner
205
-        $lowNet = array();
206
-        $scores =array();
207
-        foreach ($matchRound as $key => $match){
208
-            $netScore = ($match['score'] - round($match['player']->handicap,0)); //calculate net score
209
-            $lowNet[$match['player']->id] = $netScore;
210
-        }
211
-        $arrayLowNet = array_keys($lowNet, min($lowNet));
212
-
213
-        foreach($arrayLowNet as $key => $lownetPlayer) {
214
-            $netWinner = new Netwinner;
215
-            $netWinner->player_id = $lownetPlayer;
216
-            $netWinner->match_id = $matchdata['match'];
217
-            $netWinner->score = $lowNet[$lownetPlayer];
218
-            $netWinner->money = $this->prizeMoney->getlowScore() /  count($arrayLowNet);
219
-            $netWinner->save();
220
-        }
221
-
222
-        //Calculate Skins
223
-
224
-        //determine A and B players
225
-        //using pivot table match_player
226
-        $match = $this->match->find($matchdata['match']);
227
-        $aPlayers = array();
228
-        $bPlayers = array();
229
-        foreach($match->players as $player)
230
-        {
231
-            if($player->pivot->level_id == 1){
232
-                $aPlayers[] = $player->pivot->player_id;
233
-
234
-            }
235
-            if($player->pivot->level_id == 2){
236
-                $bPlayers[] = $player->pivot->player_id;
237
-            }
238
-        }
239
-
240
-        //Create Skins arrays
241
-        //player_id, 'holescores'
242
-        foreach($matchRound as $key => $round) {
243
-            if (in_array($round->player_id,$aPlayers)){
244
-                $aPlayersSkins[$key]['player_id'] = $round->player_id;
245
-                $aPlayersSkins[$key]['holescores'] = $round->holescores;
246
-            }
247
-            if (in_array($round->player_id,$bPlayers)){
248
-                $bPlayersSkins[$key]['player_id'] = $round->player_id;
249
-                $bPlayersSkins[$key]['holescores'] = $round->holescores;
250
-            }
251
-        }
252
-
253
-        //Run A Skins analysis
254
-        $scores = array();
255
-        foreach($aPlayersSkins as $key => $playerSkin){
256
-            foreach($playerSkin['holescores'] as $hole => $holescore){
257
-                $scores[$holescore['hole_id']][$playerSkin['player_id']] = $holescore['score'];
258
-            }
259
-        }
260
-
261
-        foreach($scores as $hole_id => $hole) {
262
-            $minScore = min($hole);
263
-            $winners[$hole_id] = array_keys($hole, min($hole)); //gets player id of lowest score
264
-        }
265
-        $aSkinsWon = 0;
266
-        foreach($winners as $key => $winner) {
267
-            if(count($winner)  ===  1) {
268
-                //post to DB
269
-                $skinWinner = new Skin;
270
-                $skinWinner->player_id = $winner[0];
271
-                $skinWinner->level_id = 1;
272
-                $skinWinner->match_id = intval($matchdata['match']);
273
-                $skinWinner->hole_id = $key;
274
-                $skinWinner->save();
275
-                $aSkinsWon++;
276
-            }
277
-        }
278
-
279
-        //Run B Skins analysis
280
-        $scores = array();
281
-        foreach($bPlayersSkins as $key => $playerSkin){
282
-            foreach($playerSkin['holescores'] as $hole => $holescore){
283
-                $scores[$holescore['hole_id']][$playerSkin['player_id']] = $holescore['score'];
284
-            }
285
-        }
286
-
287
-        foreach($scores as $hole_id => $hole) {
288
-            $minScore = min($hole);
289
-            $winners[$hole_id] = array_keys($hole, min($hole)); //gets player id of lowest score
290
-        }
291
-        $bSkinsWon = 0;
292
-        foreach($winners as $key => $winner) {
293
-            if(count($winner)  ===  1) {
294
-                //post to DB
295
-                $skinWinner = new Skin;
296
-                $skinWinner->player_id = $winner[0];
297
-                $skinWinner->level_id = 2;
298
-                $skinWinner->match_id = intval($matchdata['match']);
299
-                $skinWinner->hole_id = $key;
300
-                $skinWinner->save();
301
-                $bSkinsWon++;
302
-            }
303
-        }
304
-
305
-        $match =  Match::find($matchdata['match']);
306
-
307
-        //Need to add Carry over money if there no skins are won
308
-        //check for carry over money
309
-        $skinsamoney = $match->skinsamoney; // + carryover A money if any
310
-        $skinsbmoney = $match->skinsbmoney; // + carryover B money if any
311
-
312
-        if($aSkinsWon > 0) {
313
-            $moneyperskinA = $skinsamoney / $aSkinsWon;
314
-
315
-            $aSkins = Skin::where('match_id', '=', $matchdata['match'])->where('level_id', '=', 1)->get();
316
-            foreach ($aSkins as $askin){
317
-                $askin->money = $moneyperskinA;
318
-                $askin->save();
319
-            }
320
-        }
321
-
322
-        if($bSkinsWon > 0) {
323
-            $moneyperskinB = $skinsbmoney / $bSkinsWon;
324
-
325
-            $bSkins = Skin::where('match_id', '=', $matchdata['match'])->where('level_id', '=', 2)->get();
326
-            foreach ($bSkins as $bskin){
327
-                $bskin->money = $moneyperskinB;
328
-                $bskin->save();
329
-            }
330
-        }
331
-        //foreach player in pivot table create player and run handicap analysis
332
-        foreach($match->players as $matchplayer)
333
-        {
334
-            $player = Player::find($matchplayer->pivot->player_id);
335
-            $handicap = new Handicap($player);
336
-            $player->handicap = $handicap->calculate();
337
-            $player->save();
338
-        }
339
-
340
-        //Fire event to calculate money won and add to pivot table match_player
341
-        $this->events->fire('match.finalize', $match);
342
-
343
-    }
344
-
345
-    /**
346
-     * Method to get match from input Match data
347
-     *
348
-     * @param mixed $matchdata
349
-     * @return JSON object
350
-     */
351
-    public function get($matchid)
352
-    {
353
-        $matchdata =  $this->matchRepo->get($matchid);
354
-        return $matchdata;
355
-    }
356
-
357
-
358
-
359
-    private function search($array, $key, $value)
360
-    {
361
-        $results = array();
362
-        if (is_array($array)) {
363
-            if (isset($array[$key]) && $array[$key] == $value) {
364
-                $results[] = $array;
365
-            }
366
-            foreach ($array as $subarray) {
367
-                $results = array_merge($results, $this->search($subarray, $key, $value));
368
-            }
369
-        }
370
-        return $results;
371
-    }
69
+		$bPlayerCount = 0;
70
+		foreach($matchdata['player'] as $player){
71
+			if ($player['level_id'] == '1'){
72
+				$aPlayerCount++;
73
+			}
74
+			else {
75
+				$bPlayerCount++;
76
+			}
77
+			$totalPlayers++;
78
+		}
79
+
80
+		//Calculate Skins money based on how many players in each group
81
+
82
+		$matchdata['skinsamoney'] = $this->prizeMoney->skinsGroupPot($matchdata['purse'], $totalPlayers, $aPlayerCount);
83
+		$matchdata['skinsbmoney'] = $this->prizeMoney->skinsGroupPot($matchdata['purse'], $totalPlayers, $bPlayerCount);
84
+		//check for carry over money and if there is add it to skins money
85
+		$carryOver = new CarryOver;
86
+		$carryOverMoney = $carryOver->calculate();
87
+		$matchdata['skinsamoney'] +=  $carryOverMoney[1];
88
+		$matchdata['skinsbmoney'] +=  $carryOverMoney[2];
89
+
90
+		//append current handicap and set winnings to 0 for each player
91
+		foreach ($matchdata['player'] as $key=>$player) {
92
+			//get each player's current handicap
93
+			$currentPlayer = $this->player->find($player['player_id']);
94
+			$matchdata['player'][$key]['handicap'] = $currentPlayer->handicap;
95
+			$matchdata['player'][$key]['winnings'] = 0;
96
+		}// End foreach
97
+
98
+		$matchid = $this->matchRepo->create($matchdata);
99
+		$matchdata['match_id'] = $matchid;
100
+		$this->events->fire('match.create', array($matchdata));  // MatchHandler and teamMatchHandler are listening...
101
+
102
+		// Run for team Matches
103
+		if($matchdata['matchType'] === 'team' || $matchdata['matchType'] === 'both'){
104
+
105
+			foreach ($matchdata['teamMatchUp1'] as $teamKey => $team){
106
+				$matchUp1[] = $this->search($matchdata['player'], 'team', $team);
107
+			}
108
+
109
+			//Save matchUp 1
110
+			$match1['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
111
+			$match1['team_id'] = $matchUp1[0][0]['team'];
112
+			$match1['player1'] = $matchUp1[0][0]['player_id'];
113
+			$match1['player2'] = $matchUp1[0][1]['player_id'];
114
+			$match1['opponent'] = $matchUp1[1][0]['team'];
115
+			$this->teammatch->create($match1); //save to match table
116
+
117
+			$match1['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
118
+			$match1['team_id'] = $matchUp1[1][0]['team'];
119
+			$match1['player1'] = $matchUp1[1][0]['player_id'];
120
+			$match1['player2'] = $matchUp1[1][1]['player_id'];
121
+			$match1['opponent'] = $matchUp1[0][0]['team'];
122
+			$this->teammatch->create($match1); //save to match table
123
+
124
+
125
+			foreach ($matchdata['teamMatchUp2'] as $teamKey => $team){
126
+				$matchUp2[] = $this->search($matchdata['player'], 'team', $team);
127
+			}
128
+
129
+			//Save matchUp 2
130
+			$match2['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
131
+			$match2['team_id'] = $matchUp2[0][0]['team'];
132
+			$match2['player1'] = $matchUp2[0][0]['player_id'];
133
+			$match2['player2'] = $matchUp2[0][1]['player_id'];
134
+			$match2['opponent'] = $matchUp2[1][0]['team'];
135
+			$this->teammatch->create($match2); //save to match table
136
+
137
+			$match2['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
138
+			$match2['team_id'] = $matchUp2[1][0]['team'];
139
+			$match2['player1'] = $matchUp2[1][0]['player_id'];
140
+			$match2['player2'] = $matchUp2[1][1]['player_id'];
141
+			$match2['opponent'] = $matchUp2[0][0]['team'];
142
+			$this->teammatch->create($match2); //save to match table
143
+
144
+
145
+			foreach ($matchdata['teamMatchUp3'] as $teamKey => $team){
146
+				$matchUp3[] = $this->search($matchdata['player'], 'team', $team);
147
+			}
148
+
149
+			//Save matchUp 3
150
+			$match3['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
151
+			$match3['team_id'] = $matchUp3[0][0]['team'];
152
+			$match3['player1'] = $matchUp3[0][0]['player_id'];
153
+			$match3['player2'] = $matchUp3[0][1]['player_id'];
154
+			$match3['opponent'] = $matchUp3[1][0]['team'];
155
+			$this->teammatch->create($match3); //save to match table
156
+
157
+			$match3['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
158
+			$match3['team_id'] = $matchUp3[1][0]['team'];
159
+			$match3['player1'] = $matchUp3[1][0]['player_id'];
160
+			$match3['player2'] = $matchUp3[1][1]['player_id'];
161
+			$match3['opponent'] = $matchUp3[0][0]['team'];
162
+			$this->teammatch->create($match3); //save to match table
163
+
164
+		}
165
+	}
166
+
167
+	public function finalize($matchdata)
168
+	{
169
+		// post CTP1 and CTP2
170
+		$ctp1 = array(
171
+			'match_id' => $matchdata['match'],
172
+			'player_id' => $matchdata['ctp1'],
173
+			'hole_id' => $matchdata['ctp1hole'],
174
+			'money' => $this->prizeMoney->getCtp()
175
+		);
176
+		$this->ctp->create($ctp1);
177
+		$ctp2 = array(
178
+			'match_id' => $matchdata['match'],
179
+			'player_id' => $matchdata['ctp2'],
180
+			'hole_id' => $matchdata['ctp2hole'],
181
+			'money' => $this->prizeMoney->getCtp()
182
+		);
183
+		$this->ctp->create($ctp2);
184
+
185
+		//calculate Gross winner and post to grossWinnersTable
186
+
187
+		$matchRound = $this->matchRoundRepo->getByMatch($matchdata['match']);
188
+
189
+
190
+		$lowGross = array();
191
+		foreach ($matchRound as $key => $match){
192
+			$lowGross[$match['player']->id] = $match['score'];
193
+		}
194
+		$arrayLowGross = array_keys($lowGross, min($lowGross));
195
+		foreach($arrayLowGross as $key => $lowgrossPlayer) {
196
+			$grossWinner = new Grosswinner;
197
+			$grossWinner->player_id = $lowgrossPlayer;
198
+			$grossWinner->match_id = $matchdata['match'];
199
+			$grossWinner->score = $lowGross[$lowgrossPlayer];
200
+			$grossWinner->money = $this->prizeMoney->getlowScore() / count($arrayLowGross);
201
+			$grossWinner->save();
202
+		}
203
+
204
+		//Calculate NET winner
205
+		$lowNet = array();
206
+		$scores =array();
207
+		foreach ($matchRound as $key => $match){
208
+			$netScore = ($match['score'] - round($match['player']->handicap,0)); //calculate net score
209
+			$lowNet[$match['player']->id] = $netScore;
210
+		}
211
+		$arrayLowNet = array_keys($lowNet, min($lowNet));
212
+
213
+		foreach($arrayLowNet as $key => $lownetPlayer) {
214
+			$netWinner = new Netwinner;
215
+			$netWinner->player_id = $lownetPlayer;
216
+			$netWinner->match_id = $matchdata['match'];
217
+			$netWinner->score = $lowNet[$lownetPlayer];
218
+			$netWinner->money = $this->prizeMoney->getlowScore() /  count($arrayLowNet);
219
+			$netWinner->save();
220
+		}
221
+
222
+		//Calculate Skins
223
+
224
+		//determine A and B players
225
+		//using pivot table match_player
226
+		$match = $this->match->find($matchdata['match']);
227
+		$aPlayers = array();
228
+		$bPlayers = array();
229
+		foreach($match->players as $player)
230
+		{
231
+			if($player->pivot->level_id == 1){
232
+				$aPlayers[] = $player->pivot->player_id;
233
+
234
+			}
235
+			if($player->pivot->level_id == 2){
236
+				$bPlayers[] = $player->pivot->player_id;
237
+			}
238
+		}
239
+
240
+		//Create Skins arrays
241
+		//player_id, 'holescores'
242
+		foreach($matchRound as $key => $round) {
243
+			if (in_array($round->player_id,$aPlayers)){
244
+				$aPlayersSkins[$key]['player_id'] = $round->player_id;
245
+				$aPlayersSkins[$key]['holescores'] = $round->holescores;
246
+			}
247
+			if (in_array($round->player_id,$bPlayers)){
248
+				$bPlayersSkins[$key]['player_id'] = $round->player_id;
249
+				$bPlayersSkins[$key]['holescores'] = $round->holescores;
250
+			}
251
+		}
252
+
253
+		//Run A Skins analysis
254
+		$scores = array();
255
+		foreach($aPlayersSkins as $key => $playerSkin){
256
+			foreach($playerSkin['holescores'] as $hole => $holescore){
257
+				$scores[$holescore['hole_id']][$playerSkin['player_id']] = $holescore['score'];
258
+			}
259
+		}
260
+
261
+		foreach($scores as $hole_id => $hole) {
262
+			$minScore = min($hole);
263
+			$winners[$hole_id] = array_keys($hole, min($hole)); //gets player id of lowest score
264
+		}
265
+		$aSkinsWon = 0;
266
+		foreach($winners as $key => $winner) {
267
+			if(count($winner)  ===  1) {
268
+				//post to DB
269
+				$skinWinner = new Skin;
270
+				$skinWinner->player_id = $winner[0];
271
+				$skinWinner->level_id = 1;
272
+				$skinWinner->match_id = intval($matchdata['match']);
273
+				$skinWinner->hole_id = $key;
274
+				$skinWinner->save();
275
+				$aSkinsWon++;
276
+			}
277
+		}
278
+
279
+		//Run B Skins analysis
280
+		$scores = array();
281
+		foreach($bPlayersSkins as $key => $playerSkin){
282
+			foreach($playerSkin['holescores'] as $hole => $holescore){
283
+				$scores[$holescore['hole_id']][$playerSkin['player_id']] = $holescore['score'];
284
+			}
285
+		}
286
+
287
+		foreach($scores as $hole_id => $hole) {
288
+			$minScore = min($hole);
289
+			$winners[$hole_id] = array_keys($hole, min($hole)); //gets player id of lowest score
290
+		}
291
+		$bSkinsWon = 0;
292
+		foreach($winners as $key => $winner) {
293
+			if(count($winner)  ===  1) {
294
+				//post to DB
295
+				$skinWinner = new Skin;
296
+				$skinWinner->player_id = $winner[0];
297
+				$skinWinner->level_id = 2;
298
+				$skinWinner->match_id = intval($matchdata['match']);
299
+				$skinWinner->hole_id = $key;
300
+				$skinWinner->save();
301
+				$bSkinsWon++;
302
+			}
303
+		}
304
+
305
+		$match =  Match::find($matchdata['match']);
306
+
307
+		//Need to add Carry over money if there no skins are won
308
+		//check for carry over money
309
+		$skinsamoney = $match->skinsamoney; // + carryover A money if any
310
+		$skinsbmoney = $match->skinsbmoney; // + carryover B money if any
311
+
312
+		if($aSkinsWon > 0) {
313
+			$moneyperskinA = $skinsamoney / $aSkinsWon;
314
+
315
+			$aSkins = Skin::where('match_id', '=', $matchdata['match'])->where('level_id', '=', 1)->get();
316
+			foreach ($aSkins as $askin){
317
+				$askin->money = $moneyperskinA;
318
+				$askin->save();
319
+			}
320
+		}
321
+
322
+		if($bSkinsWon > 0) {
323
+			$moneyperskinB = $skinsbmoney / $bSkinsWon;
324
+
325
+			$bSkins = Skin::where('match_id', '=', $matchdata['match'])->where('level_id', '=', 2)->get();
326
+			foreach ($bSkins as $bskin){
327
+				$bskin->money = $moneyperskinB;
328
+				$bskin->save();
329
+			}
330
+		}
331
+		//foreach player in pivot table create player and run handicap analysis
332
+		foreach($match->players as $matchplayer)
333
+		{
334
+			$player = Player::find($matchplayer->pivot->player_id);
335
+			$handicap = new Handicap($player);
336
+			$player->handicap = $handicap->calculate();
337
+			$player->save();
338
+		}
339
+
340
+		//Fire event to calculate money won and add to pivot table match_player
341
+		$this->events->fire('match.finalize', $match);
342
+
343
+	}
344
+
345
+	/**
346
+	 * Method to get match from input Match data
347
+	 *
348
+	 * @param mixed $matchdata
349
+	 * @return JSON object
350
+	 */
351
+	public function get($matchid)
352
+	{
353
+		$matchdata =  $this->matchRepo->get($matchid);
354
+		return $matchdata;
355
+	}
356
+
357
+
358
+
359
+	private function search($array, $key, $value)
360
+	{
361
+		$results = array();
362
+		if (is_array($array)) {
363
+			if (isset($array[$key]) && $array[$key] == $value) {
364
+				$results[] = $array;
365
+			}
366
+			foreach ($array as $subarray) {
367
+				$results = array_merge($results, $this->search($subarray, $key, $value));
368
+			}
369
+		}
370
+		return $results;
371
+	}
372 372
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
         $aPlayerCount = 0;
68 68
         
69 69
         $bPlayerCount = 0;
70
-        foreach($matchdata['player'] as $player){
71
-            if ($player['level_id'] == '1'){
70
+        foreach ($matchdata['player'] as $player) {
71
+            if ($player['level_id'] == '1') {
72 72
                 $aPlayerCount++;
73 73
             }
74 74
             else {
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
         //check for carry over money and if there is add it to skins money
85 85
         $carryOver = new CarryOver;
86 86
         $carryOverMoney = $carryOver->calculate();
87
-        $matchdata['skinsamoney'] +=  $carryOverMoney[1];
88
-        $matchdata['skinsbmoney'] +=  $carryOverMoney[2];
87
+        $matchdata['skinsamoney'] += $carryOverMoney[1];
88
+        $matchdata['skinsbmoney'] += $carryOverMoney[2];
89 89
 
90 90
         //append current handicap and set winnings to 0 for each player
91 91
         foreach ($matchdata['player'] as $key=>$player) {
@@ -97,24 +97,24 @@  discard block
 block discarded – undo
97 97
 
98 98
         $matchid = $this->matchRepo->create($matchdata);
99 99
         $matchdata['match_id'] = $matchid;
100
-        $this->events->fire('match.create', array($matchdata));  // MatchHandler and teamMatchHandler are listening...
100
+        $this->events->fire('match.create', array($matchdata)); // MatchHandler and teamMatchHandler are listening...
101 101
 
102 102
         // Run for team Matches
103
-        if($matchdata['matchType'] === 'team' || $matchdata['matchType'] === 'both'){
103
+        if ($matchdata['matchType'] === 'team' || $matchdata['matchType'] === 'both') {
104 104
 
105
-            foreach ($matchdata['teamMatchUp1'] as $teamKey => $team){
105
+            foreach ($matchdata['teamMatchUp1'] as $teamKey => $team) {
106 106
                 $matchUp1[] = $this->search($matchdata['player'], 'team', $team);
107 107
             }
108 108
 
109 109
             //Save matchUp 1
110
-            $match1['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
110
+            $match1['match_id'] = $matchdata['match_id']; // This is generated below and passed to listener
111 111
             $match1['team_id'] = $matchUp1[0][0]['team'];
112 112
             $match1['player1'] = $matchUp1[0][0]['player_id'];
113 113
             $match1['player2'] = $matchUp1[0][1]['player_id'];
114 114
             $match1['opponent'] = $matchUp1[1][0]['team'];
115 115
             $this->teammatch->create($match1); //save to match table
116 116
 
117
-            $match1['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
117
+            $match1['match_id'] = $matchdata['match_id']; // This is generated below and passed to listener
118 118
             $match1['team_id'] = $matchUp1[1][0]['team'];
119 119
             $match1['player1'] = $matchUp1[1][0]['player_id'];
120 120
             $match1['player2'] = $matchUp1[1][1]['player_id'];
@@ -122,19 +122,19 @@  discard block
 block discarded – undo
122 122
             $this->teammatch->create($match1); //save to match table
123 123
 
124 124
 
125
-            foreach ($matchdata['teamMatchUp2'] as $teamKey => $team){
125
+            foreach ($matchdata['teamMatchUp2'] as $teamKey => $team) {
126 126
                 $matchUp2[] = $this->search($matchdata['player'], 'team', $team);
127 127
             }
128 128
 
129 129
             //Save matchUp 2
130
-            $match2['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
130
+            $match2['match_id'] = $matchdata['match_id']; // This is generated below and passed to listener
131 131
             $match2['team_id'] = $matchUp2[0][0]['team'];
132 132
             $match2['player1'] = $matchUp2[0][0]['player_id'];
133 133
             $match2['player2'] = $matchUp2[0][1]['player_id'];
134 134
             $match2['opponent'] = $matchUp2[1][0]['team'];
135 135
             $this->teammatch->create($match2); //save to match table
136 136
 
137
-            $match2['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
137
+            $match2['match_id'] = $matchdata['match_id']; // This is generated below and passed to listener
138 138
             $match2['team_id'] = $matchUp2[1][0]['team'];
139 139
             $match2['player1'] = $matchUp2[1][0]['player_id'];
140 140
             $match2['player2'] = $matchUp2[1][1]['player_id'];
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
             $this->teammatch->create($match2); //save to match table
143 143
 
144 144
 
145
-            foreach ($matchdata['teamMatchUp3'] as $teamKey => $team){
145
+            foreach ($matchdata['teamMatchUp3'] as $teamKey => $team) {
146 146
                 $matchUp3[] = $this->search($matchdata['player'], 'team', $team);
147 147
             }
148 148
 
149 149
             //Save matchUp 3
150
-            $match3['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
150
+            $match3['match_id'] = $matchdata['match_id']; // This is generated below and passed to listener
151 151
             $match3['team_id'] = $matchUp3[0][0]['team'];
152 152
             $match3['player1'] = $matchUp3[0][0]['player_id'];
153 153
             $match3['player2'] = $matchUp3[0][1]['player_id'];
154 154
             $match3['opponent'] = $matchUp3[1][0]['team'];
155 155
             $this->teammatch->create($match3); //save to match table
156 156
 
157
-            $match3['match_id'] = $matchdata['match_id'];  // This is generated below and passed to listener
157
+            $match3['match_id'] = $matchdata['match_id']; // This is generated below and passed to listener
158 158
             $match3['team_id'] = $matchUp3[1][0]['team'];
159 159
             $match3['player1'] = $matchUp3[1][0]['player_id'];
160 160
             $match3['player2'] = $matchUp3[1][1]['player_id'];
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 
189 189
 
190 190
         $lowGross = array();
191
-        foreach ($matchRound as $key => $match){
191
+        foreach ($matchRound as $key => $match) {
192 192
             $lowGross[$match['player']->id] = $match['score'];
193 193
         }
194 194
         $arrayLowGross = array_keys($lowGross, min($lowGross));
195
-        foreach($arrayLowGross as $key => $lowgrossPlayer) {
195
+        foreach ($arrayLowGross as $key => $lowgrossPlayer) {
196 196
             $grossWinner = new Grosswinner;
197 197
             $grossWinner->player_id = $lowgrossPlayer;
198 198
             $grossWinner->match_id = $matchdata['match'];
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 
204 204
         //Calculate NET winner
205 205
         $lowNet = array();
206
-        $scores =array();
207
-        foreach ($matchRound as $key => $match){
208
-            $netScore = ($match['score'] - round($match['player']->handicap,0)); //calculate net score
206
+        $scores = array();
207
+        foreach ($matchRound as $key => $match) {
208
+            $netScore = ($match['score'] - round($match['player']->handicap, 0)); //calculate net score
209 209
             $lowNet[$match['player']->id] = $netScore;
210 210
         }
211 211
         $arrayLowNet = array_keys($lowNet, min($lowNet));
212 212
 
213
-        foreach($arrayLowNet as $key => $lownetPlayer) {
213
+        foreach ($arrayLowNet as $key => $lownetPlayer) {
214 214
             $netWinner = new Netwinner;
215 215
             $netWinner->player_id = $lownetPlayer;
216 216
             $netWinner->match_id = $matchdata['match'];
217 217
             $netWinner->score = $lowNet[$lownetPlayer];
218
-            $netWinner->money = $this->prizeMoney->getlowScore() /  count($arrayLowNet);
218
+            $netWinner->money = $this->prizeMoney->getlowScore() / count($arrayLowNet);
219 219
             $netWinner->save();
220 220
         }
221 221
 
@@ -226,25 +226,25 @@  discard block
 block discarded – undo
226 226
         $match = $this->match->find($matchdata['match']);
227 227
         $aPlayers = array();
228 228
         $bPlayers = array();
229
-        foreach($match->players as $player)
229
+        foreach ($match->players as $player)
230 230
         {
231
-            if($player->pivot->level_id == 1){
231
+            if ($player->pivot->level_id == 1) {
232 232
                 $aPlayers[] = $player->pivot->player_id;
233 233
 
234 234
             }
235
-            if($player->pivot->level_id == 2){
235
+            if ($player->pivot->level_id == 2) {
236 236
                 $bPlayers[] = $player->pivot->player_id;
237 237
             }
238 238
         }
239 239
 
240 240
         //Create Skins arrays
241 241
         //player_id, 'holescores'
242
-        foreach($matchRound as $key => $round) {
243
-            if (in_array($round->player_id,$aPlayers)){
242
+        foreach ($matchRound as $key => $round) {
243
+            if (in_array($round->player_id, $aPlayers)) {
244 244
                 $aPlayersSkins[$key]['player_id'] = $round->player_id;
245 245
                 $aPlayersSkins[$key]['holescores'] = $round->holescores;
246 246
             }
247
-            if (in_array($round->player_id,$bPlayers)){
247
+            if (in_array($round->player_id, $bPlayers)) {
248 248
                 $bPlayersSkins[$key]['player_id'] = $round->player_id;
249 249
                 $bPlayersSkins[$key]['holescores'] = $round->holescores;
250 250
             }
@@ -252,19 +252,19 @@  discard block
 block discarded – undo
252 252
 
253 253
         //Run A Skins analysis
254 254
         $scores = array();
255
-        foreach($aPlayersSkins as $key => $playerSkin){
256
-            foreach($playerSkin['holescores'] as $hole => $holescore){
255
+        foreach ($aPlayersSkins as $key => $playerSkin) {
256
+            foreach ($playerSkin['holescores'] as $hole => $holescore) {
257 257
                 $scores[$holescore['hole_id']][$playerSkin['player_id']] = $holescore['score'];
258 258
             }
259 259
         }
260 260
 
261
-        foreach($scores as $hole_id => $hole) {
261
+        foreach ($scores as $hole_id => $hole) {
262 262
             $minScore = min($hole);
263 263
             $winners[$hole_id] = array_keys($hole, min($hole)); //gets player id of lowest score
264 264
         }
265 265
         $aSkinsWon = 0;
266
-        foreach($winners as $key => $winner) {
267
-            if(count($winner)  ===  1) {
266
+        foreach ($winners as $key => $winner) {
267
+            if (count($winner) === 1) {
268 268
                 //post to DB
269 269
                 $skinWinner = new Skin;
270 270
                 $skinWinner->player_id = $winner[0];
@@ -278,19 +278,19 @@  discard block
 block discarded – undo
278 278
 
279 279
         //Run B Skins analysis
280 280
         $scores = array();
281
-        foreach($bPlayersSkins as $key => $playerSkin){
282
-            foreach($playerSkin['holescores'] as $hole => $holescore){
281
+        foreach ($bPlayersSkins as $key => $playerSkin) {
282
+            foreach ($playerSkin['holescores'] as $hole => $holescore) {
283 283
                 $scores[$holescore['hole_id']][$playerSkin['player_id']] = $holescore['score'];
284 284
             }
285 285
         }
286 286
 
287
-        foreach($scores as $hole_id => $hole) {
287
+        foreach ($scores as $hole_id => $hole) {
288 288
             $minScore = min($hole);
289 289
             $winners[$hole_id] = array_keys($hole, min($hole)); //gets player id of lowest score
290 290
         }
291 291
         $bSkinsWon = 0;
292
-        foreach($winners as $key => $winner) {
293
-            if(count($winner)  ===  1) {
292
+        foreach ($winners as $key => $winner) {
293
+            if (count($winner) === 1) {
294 294
                 //post to DB
295 295
                 $skinWinner = new Skin;
296 296
                 $skinWinner->player_id = $winner[0];
@@ -302,34 +302,34 @@  discard block
 block discarded – undo
302 302
             }
303 303
         }
304 304
 
305
-        $match =  Match::find($matchdata['match']);
305
+        $match = Match::find($matchdata['match']);
306 306
 
307 307
         //Need to add Carry over money if there no skins are won
308 308
         //check for carry over money
309 309
         $skinsamoney = $match->skinsamoney; // + carryover A money if any
310 310
         $skinsbmoney = $match->skinsbmoney; // + carryover B money if any
311 311
 
312
-        if($aSkinsWon > 0) {
312
+        if ($aSkinsWon > 0) {
313 313
             $moneyperskinA = $skinsamoney / $aSkinsWon;
314 314
 
315 315
             $aSkins = Skin::where('match_id', '=', $matchdata['match'])->where('level_id', '=', 1)->get();
316
-            foreach ($aSkins as $askin){
316
+            foreach ($aSkins as $askin) {
317 317
                 $askin->money = $moneyperskinA;
318 318
                 $askin->save();
319 319
             }
320 320
         }
321 321
 
322
-        if($bSkinsWon > 0) {
322
+        if ($bSkinsWon > 0) {
323 323
             $moneyperskinB = $skinsbmoney / $bSkinsWon;
324 324
 
325 325
             $bSkins = Skin::where('match_id', '=', $matchdata['match'])->where('level_id', '=', 2)->get();
326
-            foreach ($bSkins as $bskin){
326
+            foreach ($bSkins as $bskin) {
327 327
                 $bskin->money = $moneyperskinB;
328 328
                 $bskin->save();
329 329
             }
330 330
         }
331 331
         //foreach player in pivot table create player and run handicap analysis
332
-        foreach($match->players as $matchplayer)
332
+        foreach ($match->players as $matchplayer)
333 333
         {
334 334
             $player = Player::find($matchplayer->pivot->player_id);
335 335
             $handicap = new Handicap($player);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
      */
351 351
     public function get($matchid)
352 352
     {
353
-        $matchdata =  $this->matchRepo->get($matchid);
353
+        $matchdata = $this->matchRepo->get($matchid);
354 354
         return $matchdata;
355 355
     }
356 356
 
Please login to merge, or discard this patch.
Braces   +22 added lines, -26 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Our MatchService, containing all useful methods for business logic around Matches
19 19
  */
20
-class MatchService
21
-{
20
+class MatchService {
22 21
     // Containing our matchRepository to make all our database calls to
23 22
     protected $matchRepo;
24 23
 
@@ -67,11 +66,10 @@  discard block
 block discarded – undo
67 66
         $aPlayerCount = 0;
68 67
         
69 68
         $bPlayerCount = 0;
70
-        foreach($matchdata['player'] as $player){
71
-            if ($player['level_id'] == '1'){
69
+        foreach($matchdata['player'] as $player) {
70
+            if ($player['level_id'] == '1') {
72 71
                 $aPlayerCount++;
73
-            }
74
-            else {
72
+            } else {
75 73
                 $bPlayerCount++;
76 74
             }
77 75
             $totalPlayers++;
@@ -100,9 +98,9 @@  discard block
 block discarded – undo
100 98
         $this->events->fire('match.create', array($matchdata));  // MatchHandler and teamMatchHandler are listening...
101 99
 
102 100
         // Run for team Matches
103
-        if($matchdata['matchType'] === 'team' || $matchdata['matchType'] === 'both'){
101
+        if($matchdata['matchType'] === 'team' || $matchdata['matchType'] === 'both') {
104 102
 
105
-            foreach ($matchdata['teamMatchUp1'] as $teamKey => $team){
103
+            foreach ($matchdata['teamMatchUp1'] as $teamKey => $team) {
106 104
                 $matchUp1[] = $this->search($matchdata['player'], 'team', $team);
107 105
             }
108 106
 
@@ -122,7 +120,7 @@  discard block
 block discarded – undo
122 120
             $this->teammatch->create($match1); //save to match table
123 121
 
124 122
 
125
-            foreach ($matchdata['teamMatchUp2'] as $teamKey => $team){
123
+            foreach ($matchdata['teamMatchUp2'] as $teamKey => $team) {
126 124
                 $matchUp2[] = $this->search($matchdata['player'], 'team', $team);
127 125
             }
128 126
 
@@ -142,7 +140,7 @@  discard block
 block discarded – undo
142 140
             $this->teammatch->create($match2); //save to match table
143 141
 
144 142
 
145
-            foreach ($matchdata['teamMatchUp3'] as $teamKey => $team){
143
+            foreach ($matchdata['teamMatchUp3'] as $teamKey => $team) {
146 144
                 $matchUp3[] = $this->search($matchdata['player'], 'team', $team);
147 145
             }
148 146
 
@@ -188,7 +186,7 @@  discard block
 block discarded – undo
188 186
 
189 187
 
190 188
         $lowGross = array();
191
-        foreach ($matchRound as $key => $match){
189
+        foreach ($matchRound as $key => $match) {
192 190
             $lowGross[$match['player']->id] = $match['score'];
193 191
         }
194 192
         $arrayLowGross = array_keys($lowGross, min($lowGross));
@@ -204,7 +202,7 @@  discard block
 block discarded – undo
204 202
         //Calculate NET winner
205 203
         $lowNet = array();
206 204
         $scores =array();
207
-        foreach ($matchRound as $key => $match){
205
+        foreach ($matchRound as $key => $match) {
208 206
             $netScore = ($match['score'] - round($match['player']->handicap,0)); //calculate net score
209 207
             $lowNet[$match['player']->id] = $netScore;
210 208
         }
@@ -226,13 +224,12 @@  discard block
 block discarded – undo
226 224
         $match = $this->match->find($matchdata['match']);
227 225
         $aPlayers = array();
228 226
         $bPlayers = array();
229
-        foreach($match->players as $player)
230
-        {
231
-            if($player->pivot->level_id == 1){
227
+        foreach($match->players as $player) {
228
+            if($player->pivot->level_id == 1) {
232 229
                 $aPlayers[] = $player->pivot->player_id;
233 230
 
234 231
             }
235
-            if($player->pivot->level_id == 2){
232
+            if($player->pivot->level_id == 2) {
236 233
                 $bPlayers[] = $player->pivot->player_id;
237 234
             }
238 235
         }
@@ -240,11 +237,11 @@  discard block
 block discarded – undo
240 237
         //Create Skins arrays
241 238
         //player_id, 'holescores'
242 239
         foreach($matchRound as $key => $round) {
243
-            if (in_array($round->player_id,$aPlayers)){
240
+            if (in_array($round->player_id,$aPlayers)) {
244 241
                 $aPlayersSkins[$key]['player_id'] = $round->player_id;
245 242
                 $aPlayersSkins[$key]['holescores'] = $round->holescores;
246 243
             }
247
-            if (in_array($round->player_id,$bPlayers)){
244
+            if (in_array($round->player_id,$bPlayers)) {
248 245
                 $bPlayersSkins[$key]['player_id'] = $round->player_id;
249 246
                 $bPlayersSkins[$key]['holescores'] = $round->holescores;
250 247
             }
@@ -252,8 +249,8 @@  discard block
 block discarded – undo
252 249
 
253 250
         //Run A Skins analysis
254 251
         $scores = array();
255
-        foreach($aPlayersSkins as $key => $playerSkin){
256
-            foreach($playerSkin['holescores'] as $hole => $holescore){
252
+        foreach($aPlayersSkins as $key => $playerSkin) {
253
+            foreach($playerSkin['holescores'] as $hole => $holescore) {
257 254
                 $scores[$holescore['hole_id']][$playerSkin['player_id']] = $holescore['score'];
258 255
             }
259 256
         }
@@ -278,8 +275,8 @@  discard block
 block discarded – undo
278 275
 
279 276
         //Run B Skins analysis
280 277
         $scores = array();
281
-        foreach($bPlayersSkins as $key => $playerSkin){
282
-            foreach($playerSkin['holescores'] as $hole => $holescore){
278
+        foreach($bPlayersSkins as $key => $playerSkin) {
279
+            foreach($playerSkin['holescores'] as $hole => $holescore) {
283 280
                 $scores[$holescore['hole_id']][$playerSkin['player_id']] = $holescore['score'];
284 281
             }
285 282
         }
@@ -313,7 +310,7 @@  discard block
 block discarded – undo
313 310
             $moneyperskinA = $skinsamoney / $aSkinsWon;
314 311
 
315 312
             $aSkins = Skin::where('match_id', '=', $matchdata['match'])->where('level_id', '=', 1)->get();
316
-            foreach ($aSkins as $askin){
313
+            foreach ($aSkins as $askin) {
317 314
                 $askin->money = $moneyperskinA;
318 315
                 $askin->save();
319 316
             }
@@ -323,14 +320,13 @@  discard block
 block discarded – undo
323 320
             $moneyperskinB = $skinsbmoney / $bSkinsWon;
324 321
 
325 322
             $bSkins = Skin::where('match_id', '=', $matchdata['match'])->where('level_id', '=', 2)->get();
326
-            foreach ($bSkins as $bskin){
323
+            foreach ($bSkins as $bskin) {
327 324
                 $bskin->money = $moneyperskinB;
328 325
                 $bskin->save();
329 326
             }
330 327
         }
331 328
         //foreach player in pivot table create player and run handicap analysis
332
-        foreach($match->players as $matchplayer)
333
-        {
329
+        foreach($match->players as $matchplayer) {
334 330
             $player = Player::find($matchplayer->pivot->player_id);
335 331
             $handicap = new Handicap($player);
336 332
             $player->handicap = $handicap->calculate();
Please login to merge, or discard this patch.
app/models/Teammatch.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -2,22 +2,22 @@
 block discarded – undo
2 2
 
3 3
 class Teammatch extends Eloquent {
4 4
 
5
-    protected $table = 'teammatches';
6
-    protected $fillable = ['match_id', 'team_id', 'player1', 'player2', 'opponent'];
5
+	protected $table = 'teammatches';
6
+	protected $fillable = ['match_id', 'team_id', 'player1', 'player2', 'opponent'];
7 7
 
8
-    public function match()
9
-    {
10
-        return $this->belongsTo('Match');
11
-    }
8
+	public function match()
9
+	{
10
+		return $this->belongsTo('Match');
11
+	}
12 12
 
13
-    public function team()
14
-    {
15
-        return $this->belongsTo('Team');
16
-    }
13
+	public function team()
14
+	{
15
+		return $this->belongsTo('Team');
16
+	}
17 17
 
18
-    public function player()
19
-    {
20
-        return $this->belongsTo('Player');
21
-    }
18
+	public function player()
19
+	{
20
+		return $this->belongsTo('Player');
21
+	}
22 22
 
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
app/routes.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@
 block discarded – undo
12 12
 */
13 13
 Route::get('/', function()
14 14
 {
15
-    return Redirect::to('schedule');
15
+	return Redirect::to('schedule');
16 16
 });
17 17
 
18 18
 Route::get('/test', function()
19 19
 {
20 20
 
21
-    $players = new \Player();
22
-    $players = $players->all();
23
-    //echo $players;
21
+	$players = new \Player();
22
+	$players = $players->all();
23
+	//echo $players;
24 24
    foreach ($players as $player){
25
-       $handicap = new \GolfLeague\Handicap($player);
26
-       $player->handicap = $handicap->calculate();
27
-       echo $player->name . " " . $player->handicap . "<br>";
28
-       $player->save();
25
+	   $handicap = new \GolfLeague\Handicap($player);
26
+	   $player->handicap = $handicap->calculate();
27
+	   echo $player->name . " " . $player->handicap . "<br>";
28
+	   $player->save();
29 29
    }
30 30
 });
31 31
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
     $players = new \Player();
22 22
     $players = $players->all();
23 23
     //echo $players;
24
-   foreach ($players as $player){
24
+   foreach ($players as $player) {
25 25
        $handicap = new \GolfLeague\Handicap($player);
26 26
        $player->handicap = $handicap->calculate();
27
-       echo $player->name . " " . $player->handicap . "<br>";
27
+       echo $player->name." ".$player->handicap."<br>";
28 28
        $player->save();
29 29
    }
30 30
 });
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 Route::resource('leaderboard', 'LeaderboardController');
62 62
 Route::resource('tournament', 'TournamentController');
63 63
 Route::resource('tournamentLeaderboard', 'TournamentLeaderboardController');
64
-Route::resource('teammatches','TeamMatchesController');
65
-Route::get('teammatches/points/{year}','TeamMatchesController@getPointsByYear');
64
+Route::resource('teammatches', 'TeamMatchesController');
65
+Route::get('teammatches/points/{year}', 'TeamMatchesController@getPointsByYear');
66 66
 Route::resource('team', 'TeamController');
67 67
 Route::get('team/year/{year}', 'TeamController@findByYear');
68 68
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     $players = new \Player();
22 22
     $players = $players->all();
23 23
     //echo $players;
24
-   foreach ($players as $player){
24
+   foreach ($players as $player) {
25 25
        $handicap = new \GolfLeague\Handicap($player);
26 26
        $player->handicap = $handicap->calculate();
27 27
        echo $player->name . " " . $player->handicap . "<br>";
Please login to merge, or discard this patch.
app/controllers/TeamController.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@  discard block
 block discarded – undo
4 4
 
5 5
 class TeamController extends \BaseController {
6 6
 
7
-    private $team;
7
+	private $team;
8 8
 
9
-    public function __construct(TeamRepo $team)
10
-    {
11
-        $this->team = $team;
12
-    }
13
-    /**
9
+	public function __construct(TeamRepo $team)
10
+	{
11
+		$this->team = $team;
12
+	}
13
+	/**
14 14
 	 * Display a listing of the resource.
15 15
 	 *
16 16
 	 * @return Response
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 		//
43 43
 	}
44 44
 
45
-    /**
46
-     * Display a listing of the teams by year .
47
-     *
48
-     * @return Response
49
-     */
45
+	/**
46
+	 * Display a listing of the teams by year .
47
+	 *
48
+	 * @return Response
49
+	 */
50 50
 	public function findByYear($year)
51
-    {
52
-        return $this->team->findByYear($year);
53
-    }
51
+	{
52
+		return $this->team->findByYear($year);
53
+	}
54 54
 
55 55
 	/**
56 56
 	 * Display the specified resource.
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
      * @return Response
49 49
      */
50 50
 	public function findByYear($year)
51
-    {
51
+	{
52 52
         return $this->team->findByYear($year);
53 53
     }
54 54
 
Please login to merge, or discard this patch.
app/controllers/MatchesController.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
 class MatchesController extends \BaseController {
8 8
 
9 9
 
10
-    public function __construct(MatchService $match, MatchRepository $matchRepo)
11
-    {
12
-        $this->match = $match;
10
+	public function __construct(MatchService $match, MatchRepository $matchRepo)
11
+	{
12
+		$this->match = $match;
13 13
 		$this->matchRepo = $matchRepo;
14
-    }
14
+	}
15 15
 
16 16
 	/**
17 17
 	 * Display a listing of the resource.
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	public function create()
33 33
 	{
34 34
 		$view = View::make('creatematch');
35
-        return $view;
35
+		return $view;
36 36
 	}
37 37
 
38 38
 	/**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public function store()
44 44
 	{
45
-	    $input = Input::all();
45
+		$input = Input::all();
46 46
 		return $this->match->create($input);
47 47
 	}
48 48
 
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function edit($id)
69 69
 	{
70
-        $enterView = 'EnterTeamMatch';
71
-	    $data = $this->match->get($id);
72
-        $view = View::make($enterView, $data);
73
-        return $view;
70
+		$enterView = 'EnterTeamMatch';
71
+		$data = $this->match->get($id);
72
+		$view = View::make($enterView, $data);
73
+		return $view;
74 74
 		// Logic to allow editable for day of match only
75 75
 		$today = Carbon::today();
76
-        $teamMatchDate = new Carbon('first day of January 2017');
76
+		$teamMatchDate = new Carbon('first day of January 2017');
77 77
 		$matchDate = new Carbon($data['date']);
78 78
 
79 79
 		if($matchDate >= $teamMatchDate){
80
-		    $enterView = 'EnterTeamMatch';
81
-        }
80
+			$enterView = 'EnterTeamMatch';
81
+		}
82 82
 
83 83
 		if($today <= $matchDate){
84 84
 			//Show Editable View
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@
 block discarded – undo
76 76
         $teamMatchDate = new Carbon('first day of January 2017');
77 77
 		$matchDate = new Carbon($data['date']);
78 78
 
79
-		if($matchDate >= $teamMatchDate){
79
+		if ($matchDate >= $teamMatchDate) {
80 80
 		    $enterView = 'EnterTeamMatch';
81 81
         }
82 82
 
83
-		if($today <= $matchDate){
83
+		if ($today <= $matchDate) {
84 84
 			//Show Editable View
85 85
 			$view = View::make($enterView, $data);
86 86
 			return $view;
Please login to merge, or discard this patch.
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,16 +76,15 @@
 block discarded – undo
76 76
         $teamMatchDate = new Carbon('first day of January 2017');
77 77
 		$matchDate = new Carbon($data['date']);
78 78
 
79
-		if($matchDate >= $teamMatchDate){
79
+		if($matchDate >= $teamMatchDate) {
80 80
 		    $enterView = 'EnterTeamMatch';
81 81
         }
82 82
 
83
-		if($today <= $matchDate){
83
+		if($today <= $matchDate) {
84 84
 			//Show Editable View
85 85
 			$view = View::make($enterView, $data);
86 86
 			return $view;
87
-		}
88
-		else {
87
+		} else {
89 88
 			//Show Readonly View
90 89
 			$view = View::make('ViewMatch', $data);
91 90
 			return $view;
Please login to merge, or discard this patch.
app/controllers/TeamMatchesController.php 3 patches
Indentation   +213 added lines, -213 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,204 +56,204 @@  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
-            //return $team1Scores;
106
-            $team2Scores = $this->getTeamNetScore($team2, $holesData);
107
-
108
-            $team1Points = $this->calculatePoints($team1Scores, $team2Scores);
109
-            $team2Points = $this->calculatePoints($team2Scores, $team1Scores);
110
-
111
-            //Save Points in Teammatches
112
-            Teammatch::where('match_id', '=', $id)->where('team_id', '=', $team1Id)->update(array('pointsWon' => $team1Points));
113
-            Teammatch::where('match_id', '=', $id)->where('team_id', '=', $team2Id)->update(array('pointsWon' => $team2Points));
114
-
115
-
116
-        //Need to determine if same amount of scores are in both
117
-        // If not then do not return
118
-
119
-            foreach($team1Scores as $key=>$teamScore){
120
-                if($teamScore <= 0){
121
-                    $team1Scores[$key] = '';
122
-                }
123
-            }
124
-
125
-        foreach($team2Scores as $key=>$teamScore){
126
-            if($teamScore <= 0){
127
-                $team2Scores[$key] = '';
128
-            }
129
-        }
130
-
131
-        $team[0] = [
132
-            "team" =>  $team1Name[0]['name'],
133
-            "hole1" => $team1Scores[0],
134
-            "hole2" => $team1Scores[1],
135
-            "hole3" => $team1Scores[2],
136
-            "hole4" => $team1Scores[3],
137
-            "hole5" => $team1Scores[4],
138
-            "hole6" => $team1Scores[5],
139
-            "hole7" => $team1Scores[6],
140
-            "hole8" => $team1Scores[7],
141
-            "hole9" => $team1Scores[8],
142
-            "points" =>$team1Points
143
-        ];
144
-
145
-        $team[1] = [
146
-            "team" =>  $team2Name[0]['name'],
147
-            "hole1" => $team2Scores[0],
148
-            "hole2" => $team2Scores[1],
149
-            "hole3" => $team2Scores[2],
150
-            "hole4" => $team2Scores[3],
151
-            "hole5" => $team2Scores[4],
152
-            "hole6" => $team2Scores[5],
153
-            "hole7" => $team2Scores[6],
154
-            "hole8" => $team2Scores[7],
155
-            "hole9" => $team2Scores[8],
156
-            "points" => $team2Points
157
-        ];
158
-
159
-        $data['data'] = $team;
160
-        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
+			//return $team1Scores;
106
+			$team2Scores = $this->getTeamNetScore($team2, $holesData);
107
+
108
+			$team1Points = $this->calculatePoints($team1Scores, $team2Scores);
109
+			$team2Points = $this->calculatePoints($team2Scores, $team1Scores);
110
+
111
+			//Save Points in Teammatches
112
+			Teammatch::where('match_id', '=', $id)->where('team_id', '=', $team1Id)->update(array('pointsWon' => $team1Points));
113
+			Teammatch::where('match_id', '=', $id)->where('team_id', '=', $team2Id)->update(array('pointsWon' => $team2Points));
114
+
115
+
116
+		//Need to determine if same amount of scores are in both
117
+		// If not then do not return
118
+
119
+			foreach($team1Scores as $key=>$teamScore){
120
+				if($teamScore <= 0){
121
+					$team1Scores[$key] = '';
122
+				}
123
+			}
124
+
125
+		foreach($team2Scores as $key=>$teamScore){
126
+			if($teamScore <= 0){
127
+				$team2Scores[$key] = '';
128
+			}
129
+		}
130
+
131
+		$team[0] = [
132
+			"team" =>  $team1Name[0]['name'],
133
+			"hole1" => $team1Scores[0],
134
+			"hole2" => $team1Scores[1],
135
+			"hole3" => $team1Scores[2],
136
+			"hole4" => $team1Scores[3],
137
+			"hole5" => $team1Scores[4],
138
+			"hole6" => $team1Scores[5],
139
+			"hole7" => $team1Scores[6],
140
+			"hole8" => $team1Scores[7],
141
+			"hole9" => $team1Scores[8],
142
+			"points" =>$team1Points
143
+		];
144
+
145
+		$team[1] = [
146
+			"team" =>  $team2Name[0]['name'],
147
+			"hole1" => $team2Scores[0],
148
+			"hole2" => $team2Scores[1],
149
+			"hole3" => $team2Scores[2],
150
+			"hole4" => $team2Scores[3],
151
+			"hole5" => $team2Scores[4],
152
+			"hole6" => $team2Scores[5],
153
+			"hole7" => $team2Scores[6],
154
+			"hole8" => $team2Scores[7],
155
+			"hole9" => $team2Scores[8],
156
+			"points" => $team2Points
157
+		];
158
+
159
+		$data['data'] = $team;
160
+		return $data;
161 161
 	}
162 162
 
163
-    private function getTeamNetScore($team, $holesData)
164
-    {
165
-        foreach($team as $key=>$item){
166
-            // Create holes array for NET
167
-            $holes = array();
168
-            $i = 1;
169
-            foreach($holesData as $key=>$holeData){
170
-                $holes[$i] = $holeData->handicap;
171
-                $i++;
172
-            }
173
-
174
-            // Create stroke array - how many to take away from score
175
-            $strokeArray = [
176
-                1 => 0,
177
-                2 => 0,
178
-                3 => 0,
179
-                4 => 0,
180
-                5 => 0,
181
-                6 => 0,
182
-                7 => 0,
183
-                8 => 0,
184
-                9 => 0
185
-            ];
186
-            //Create array of strokes
187
-            for($counter = $item['matchHandicap']; $counter > 0; $counter--){
188
-                if($counter > 9){
189
-                    $newCounter = $counter - 9;
190
-                    while($newCounter > 0) {
191
-                        $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
192
-                        $counter--;
193
-                        $newCounter--;
194
-                    }
195
-                }
196
-                $strokeArray[$counter] = $strokeArray[$counter] + 1;
197
-            }
198
-            // Plus handicaps don't hit previous loop so need its own
199
-            //Plus handicap logic
200
-
201
-            foreach($strokeArray as $strokeKey=>$stroke){
202
-                $holeKey = array_search($strokeKey,$holes);
203
-                $holes[$holeKey] = $stroke;
204
-            }
205
-
206
-            ///now have array of strokes to subtract
207
-            //get array of holescores
208
-
209
-            $holeScores = $item['holescores'];
210
-            foreach($holeScores as $key=>$holeScore){
211
-                //check if new score is less PlayerScores
212
-                if(isset($playerScores[$key])){ // 2nd time in for hole
213
-                    if($playerScores[$key] >= $holeScore['score']){
214
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
215
-                    }
216
-                } else{ // first time in for hole
217
-                    if($holeScore['score'] != null){
218
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
219
-                    } else{
220
-                        $playerScores[$key] = null;
221
-                    }
222
-                }
223
-            }
224
-
225
-        }
226
-        return $playerScores;
227
-    }
228
-
229
-    private function calculatePoints($team, $opponent)
230
-    {
231
-        $points = 0;
232
-        $teamTotalScore = 0;
233
-        $opponentTotalScore = 0;
234
-        foreach ($team as $key=>$score){
235
-            if($score != null){
236
-                if($score < $opponent[$key]){
237
-                    $points++;
238
-                }
239
-                if($score == $opponent[$key]){
240
-                    $points = $points + .5;
241
-                }
242
-            }
243
-            $teamTotalScore = $teamTotalScore + $score;
244
-            $opponentTotalScore = $opponentTotalScore + $score;
245
-        }
246
-        // Bonus point logic
247
-        if($team[8] != null && $opponent[8] != null){
248
-            if($teamTotalScore > $opponentTotalScore){
249
-                $points = $points + 1;
250
-            }
251
-            if($teamTotalScore = $opponentTotalScore){
252
-                $points = $points + .5;
253
-            }
254
-        }
255
-        return $points;
256
-    }
163
+	private function getTeamNetScore($team, $holesData)
164
+	{
165
+		foreach($team as $key=>$item){
166
+			// Create holes array for NET
167
+			$holes = array();
168
+			$i = 1;
169
+			foreach($holesData as $key=>$holeData){
170
+				$holes[$i] = $holeData->handicap;
171
+				$i++;
172
+			}
173
+
174
+			// Create stroke array - how many to take away from score
175
+			$strokeArray = [
176
+				1 => 0,
177
+				2 => 0,
178
+				3 => 0,
179
+				4 => 0,
180
+				5 => 0,
181
+				6 => 0,
182
+				7 => 0,
183
+				8 => 0,
184
+				9 => 0
185
+			];
186
+			//Create array of strokes
187
+			for($counter = $item['matchHandicap']; $counter > 0; $counter--){
188
+				if($counter > 9){
189
+					$newCounter = $counter - 9;
190
+					while($newCounter > 0) {
191
+						$strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
192
+						$counter--;
193
+						$newCounter--;
194
+					}
195
+				}
196
+				$strokeArray[$counter] = $strokeArray[$counter] + 1;
197
+			}
198
+			// Plus handicaps don't hit previous loop so need its own
199
+			//Plus handicap logic
200
+
201
+			foreach($strokeArray as $strokeKey=>$stroke){
202
+				$holeKey = array_search($strokeKey,$holes);
203
+				$holes[$holeKey] = $stroke;
204
+			}
205
+
206
+			///now have array of strokes to subtract
207
+			//get array of holescores
208
+
209
+			$holeScores = $item['holescores'];
210
+			foreach($holeScores as $key=>$holeScore){
211
+				//check if new score is less PlayerScores
212
+				if(isset($playerScores[$key])){ // 2nd time in for hole
213
+					if($playerScores[$key] >= $holeScore['score']){
214
+						$playerScores[$key] = $holeScore['score'] - $holes[$key+1];
215
+					}
216
+				} else{ // first time in for hole
217
+					if($holeScore['score'] != null){
218
+						$playerScores[$key] = $holeScore['score'] - $holes[$key+1];
219
+					} else{
220
+						$playerScores[$key] = null;
221
+					}
222
+				}
223
+			}
224
+
225
+		}
226
+		return $playerScores;
227
+	}
228
+
229
+	private function calculatePoints($team, $opponent)
230
+	{
231
+		$points = 0;
232
+		$teamTotalScore = 0;
233
+		$opponentTotalScore = 0;
234
+		foreach ($team as $key=>$score){
235
+			if($score != null){
236
+				if($score < $opponent[$key]){
237
+					$points++;
238
+				}
239
+				if($score == $opponent[$key]){
240
+					$points = $points + .5;
241
+				}
242
+			}
243
+			$teamTotalScore = $teamTotalScore + $score;
244
+			$opponentTotalScore = $opponentTotalScore + $score;
245
+		}
246
+		// Bonus point logic
247
+		if($team[8] != null && $opponent[8] != null){
248
+			if($teamTotalScore > $opponentTotalScore){
249
+				$points = $points + 1;
250
+			}
251
+			if($teamTotalScore = $opponentTotalScore){
252
+				$points = $points + .5;
253
+			}
254
+		}
255
+		return $points;
256
+	}
257 257
 
258 258
 	/**
259 259
 	 * Show the form for editing the specified resource.
@@ -291,15 +291,15 @@  discard block
 block discarded – undo
291 291
 	}
292 292
 
293 293
 	public function getPointsByYear($year)
294
-    {
295
-        $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
296
-        foreach ($teamMatches as $key=>$teamMatch) {
297
-            $pointsData[$key]['name'] = $teamMatch['team']['name'];
298
-            $pointsData[$key]['points'] = $teamMatch['pointsWon'];
299
-        }
300
-        $data['data'] = $pointsData;
301
-        return $data;
302
-    }
294
+	{
295
+		$teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
296
+		foreach ($teamMatches as $key=>$teamMatch) {
297
+			$pointsData[$key]['name'] = $teamMatch['team']['name'];
298
+			$pointsData[$key]['points'] = $teamMatch['pointsWon'];
299
+		}
300
+		$data['data'] = $pointsData;
301
+		return $data;
302
+	}
303 303
 
304 304
 
305 305
 }
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
                 }
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
         //Need to determine if same amount of scores are in both
117 117
         // If not then do not return
118 118
 
119
-            foreach($team1Scores as $key=>$teamScore){
120
-                if($teamScore <= 0){
119
+            foreach ($team1Scores as $key=>$teamScore) {
120
+                if ($teamScore <= 0) {
121 121
                     $team1Scores[$key] = '';
122 122
                 }
123 123
             }
124 124
 
125
-        foreach($team2Scores as $key=>$teamScore){
126
-            if($teamScore <= 0){
125
+        foreach ($team2Scores as $key=>$teamScore) {
126
+            if ($teamScore <= 0) {
127 127
                 $team2Scores[$key] = '';
128 128
             }
129 129
         }
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
     private function getTeamNetScore($team, $holesData)
164 164
     {
165
-        foreach($team as $key=>$item){
165
+        foreach ($team as $key=>$item) {
166 166
             // Create holes array for NET
167 167
             $holes = array();
168 168
             $i = 1;
169
-            foreach($holesData as $key=>$holeData){
169
+            foreach ($holesData as $key=>$holeData) {
170 170
                 $holes[$i] = $holeData->handicap;
171 171
                 $i++;
172 172
             }
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
                 9 => 0
185 185
             ];
186 186
             //Create array of strokes
187
-            for($counter = $item['matchHandicap']; $counter > 0; $counter--){
188
-                if($counter > 9){
187
+            for ($counter = $item['matchHandicap']; $counter > 0; $counter--) {
188
+                if ($counter > 9) {
189 189
                     $newCounter = $counter - 9;
190
-                    while($newCounter > 0) {
190
+                    while ($newCounter > 0) {
191 191
                         $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
192 192
                         $counter--;
193 193
                         $newCounter--;
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
             // Plus handicaps don't hit previous loop so need its own
199 199
             //Plus handicap logic
200 200
 
201
-            foreach($strokeArray as $strokeKey=>$stroke){
202
-                $holeKey = array_search($strokeKey,$holes);
201
+            foreach ($strokeArray as $strokeKey=>$stroke) {
202
+                $holeKey = array_search($strokeKey, $holes);
203 203
                 $holes[$holeKey] = $stroke;
204 204
             }
205 205
 
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
             //get array of holescores
208 208
 
209 209
             $holeScores = $item['holescores'];
210
-            foreach($holeScores as $key=>$holeScore){
210
+            foreach ($holeScores as $key=>$holeScore) {
211 211
                 //check if new score is less PlayerScores
212
-                if(isset($playerScores[$key])){ // 2nd time in for hole
213
-                    if($playerScores[$key] >= $holeScore['score']){
214
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
212
+                if (isset($playerScores[$key])) { // 2nd time in for hole
213
+                    if ($playerScores[$key] >= $holeScore['score']) {
214
+                        $playerScores[$key] = $holeScore['score'] - $holes[$key + 1];
215 215
                     }
216
-                } else{ // first time in for hole
217
-                    if($holeScore['score'] != null){
218
-                        $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
219
-                    } else{
216
+                } else { // first time in for hole
217
+                    if ($holeScore['score'] != null) {
218
+                        $playerScores[$key] = $holeScore['score'] - $holes[$key + 1];
219
+                    } else {
220 220
                         $playerScores[$key] = null;
221 221
                     }
222 222
                 }
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
         $points = 0;
232 232
         $teamTotalScore = 0;
233 233
         $opponentTotalScore = 0;
234
-        foreach ($team as $key=>$score){
235
-            if($score != null){
236
-                if($score < $opponent[$key]){
234
+        foreach ($team as $key=>$score) {
235
+            if ($score != null) {
236
+                if ($score < $opponent[$key]) {
237 237
                     $points++;
238 238
                 }
239
-                if($score == $opponent[$key]){
239
+                if ($score == $opponent[$key]) {
240 240
                     $points = $points + .5;
241 241
                 }
242 242
             }
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
             $opponentTotalScore = $opponentTotalScore + $score;
245 245
         }
246 246
         // Bonus point logic
247
-        if($team[8] != null && $opponent[8] != null){
248
-            if($teamTotalScore > $opponentTotalScore){
247
+        if ($team[8] != null && $opponent[8] != null) {
248
+            if ($teamTotalScore > $opponentTotalScore) {
249 249
                 $points = $points + 1;
250 250
             }
251
-            if($teamTotalScore = $opponentTotalScore){
251
+            if ($teamTotalScore = $opponentTotalScore) {
252 252
                 $points = $points + .5;
253 253
             }
254 254
         }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
 	public function getPointsByYear($year)
294 294
     {
295
-        $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
295
+        $teamMatches = Teammatch::select('team_id', 'pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
296 296
         foreach ($teamMatches as $key=>$teamMatch) {
297 297
             $pointsData[$key]['name'] = $teamMatch['team']['name'];
298 298
             $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
                 }
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
         //Need to determine if same amount of scores are in both
117 117
         // If not then do not return
118 118
 
119
-            foreach($team1Scores as $key=>$teamScore){
120
-                if($teamScore <= 0){
119
+            foreach($team1Scores as $key=>$teamScore) {
120
+                if($teamScore <= 0) {
121 121
                     $team1Scores[$key] = '';
122 122
                 }
123 123
             }
124 124
 
125
-        foreach($team2Scores as $key=>$teamScore){
126
-            if($teamScore <= 0){
125
+        foreach($team2Scores as $key=>$teamScore) {
126
+            if($teamScore <= 0) {
127 127
                 $team2Scores[$key] = '';
128 128
             }
129 129
         }
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
     private function getTeamNetScore($team, $holesData)
164 164
     {
165
-        foreach($team as $key=>$item){
165
+        foreach($team as $key=>$item) {
166 166
             // Create holes array for NET
167 167
             $holes = array();
168 168
             $i = 1;
169
-            foreach($holesData as $key=>$holeData){
169
+            foreach($holesData as $key=>$holeData) {
170 170
                 $holes[$i] = $holeData->handicap;
171 171
                 $i++;
172 172
             }
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
                 9 => 0
185 185
             ];
186 186
             //Create array of strokes
187
-            for($counter = $item['matchHandicap']; $counter > 0; $counter--){
188
-                if($counter > 9){
187
+            for($counter = $item['matchHandicap']; $counter > 0; $counter--) {
188
+                if($counter > 9) {
189 189
                     $newCounter = $counter - 9;
190 190
                     while($newCounter > 0) {
191 191
                         $strokeArray[$newCounter] = $strokeArray[$newCounter] + 1;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
             // Plus handicaps don't hit previous loop so need its own
199 199
             //Plus handicap logic
200 200
 
201
-            foreach($strokeArray as $strokeKey=>$stroke){
201
+            foreach($strokeArray as $strokeKey=>$stroke) {
202 202
                 $holeKey = array_search($strokeKey,$holes);
203 203
                 $holes[$holeKey] = $stroke;
204 204
             }
@@ -207,16 +207,18 @@  discard block
 block discarded – undo
207 207
             //get array of holescores
208 208
 
209 209
             $holeScores = $item['holescores'];
210
-            foreach($holeScores as $key=>$holeScore){
210
+            foreach($holeScores as $key=>$holeScore) {
211 211
                 //check if new score is less PlayerScores
212
-                if(isset($playerScores[$key])){ // 2nd time in for hole
213
-                    if($playerScores[$key] >= $holeScore['score']){
212
+                if(isset($playerScores[$key])) {
213
+// 2nd time in for hole
214
+                    if($playerScores[$key] >= $holeScore['score']) {
214 215
                         $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
215 216
                     }
216
-                } else{ // first time in for hole
217
-                    if($holeScore['score'] != null){
217
+                } else {
218
+// first time in for hole
219
+                    if($holeScore['score'] != null) {
218 220
                         $playerScores[$key] = $holeScore['score'] - $holes[$key+1];
219
-                    } else{
221
+                    } else {
220 222
                         $playerScores[$key] = null;
221 223
                     }
222 224
                 }
@@ -231,12 +233,12 @@  discard block
 block discarded – undo
231 233
         $points = 0;
232 234
         $teamTotalScore = 0;
233 235
         $opponentTotalScore = 0;
234
-        foreach ($team as $key=>$score){
235
-            if($score != null){
236
-                if($score < $opponent[$key]){
236
+        foreach ($team as $key=>$score) {
237
+            if($score != null) {
238
+                if($score < $opponent[$key]) {
237 239
                     $points++;
238 240
                 }
239
-                if($score == $opponent[$key]){
241
+                if($score == $opponent[$key]) {
240 242
                     $points = $points + .5;
241 243
                 }
242 244
             }
@@ -244,11 +246,11 @@  discard block
 block discarded – undo
244 246
             $opponentTotalScore = $opponentTotalScore + $score;
245 247
         }
246 248
         // Bonus point logic
247
-        if($team[8] != null && $opponent[8] != null){
248
-            if($teamTotalScore > $opponentTotalScore){
249
+        if($team[8] != null && $opponent[8] != null) {
250
+            if($teamTotalScore > $opponentTotalScore) {
249 251
                 $points = $points + 1;
250 252
             }
251
-            if($teamTotalScore = $opponentTotalScore){
253
+            if($teamTotalScore = $opponentTotalScore) {
252 254
                 $points = $points + .5;
253 255
             }
254 256
         }
@@ -291,7 +293,7 @@  discard block
 block discarded – undo
291 293
 	}
292 294
 
293 295
 	public function getPointsByYear($year)
294
-    {
296
+	{
295 297
         $teamMatches = Teammatch::select('team_id','pointsWon')->whereYear('created_at', '=', $year)->with('team')->get();
296 298
         foreach ($teamMatches as $key=>$teamMatch) {
297 299
             $pointsData[$key]['name'] = $teamMatch['team']['name'];
Please login to merge, or discard this patch.
app/library/Storage/EloquentRepositories/EloquentTeamRepository.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -4,37 +4,37 @@
 block discarded – undo
4 4
 
5 5
 class EloquentTeamRepository implements TeamRepository
6 6
 {
7
-    private $team;
8
-
9
-    public function __construct(Team $team)
10
-    {
11
-        $this->team = $team;
12
-    }
13
-
14
-    public function all()
15
-    {
16
-        return $this->team->all();
17
-    }
18
-    public function findById($id)
19
-    {
20
-        return $this->team->where('id', '=', $id)->get();
21
-    }
22
-
23
-    public function findByYear($year)
24
-    {
25
-        return $this->team->whereYear('created_at', '=', $year)->get();
26
-    }
27
-
28
-    public function create($input)
29
-    {
30
-        $this->team->create($input);
31
-    }
32
-
33
-    public function update($team)
34
-    {
35
-        $updateTeam = $this->team->where('id', '=', $id)->get();
36
-        $updateTeam = $team;
37
-        $updateTeam->save();
38
-    }
7
+	private $team;
8
+
9
+	public function __construct(Team $team)
10
+	{
11
+		$this->team = $team;
12
+	}
13
+
14
+	public function all()
15
+	{
16
+		return $this->team->all();
17
+	}
18
+	public function findById($id)
19
+	{
20
+		return $this->team->where('id', '=', $id)->get();
21
+	}
22
+
23
+	public function findByYear($year)
24
+	{
25
+		return $this->team->whereYear('created_at', '=', $year)->get();
26
+	}
27
+
28
+	public function create($input)
29
+	{
30
+		$this->team->create($input);
31
+	}
32
+
33
+	public function update($team)
34
+	{
35
+		$updateTeam = $this->team->where('id', '=', $id)->get();
36
+		$updateTeam = $team;
37
+		$updateTeam->save();
38
+	}
39 39
 
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@
 block discarded – undo
2 2
 
3 3
 use \Team as Team;
4 4
 
5
-class EloquentTeamRepository implements TeamRepository
6
-{
5
+class EloquentTeamRepository implements TeamRepository {
7 6
     private $team;
8 7
 
9 8
     public function __construct(Team $team)
Please login to merge, or discard this patch.
app/library/Storage/EloquentRepositories/EloquentTeamMatchesRepository.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -14,35 +14,35 @@
 block discarded – undo
14 14
 
15 15
 class EloquentTeamMatchesRepository implements TeamMatchesRepository
16 16
 {
17
-    private $teamMatch;
18
-
19
-    public function __construct(Teammatch $teamMatch)
20
-    {
21
-        $this->teamMatch = $teamMatch;
22
-    }
23
-
24
-    public function all()
25
-    {
26
-        // TODO: Implement all() method.
27
-    }
28
-
29
-    public function findById($id)
30
-    {
31
-        // TODO: Implement findById() method.
32
-    }
33
-
34
-    public function create($input)
35
-    {
36
-        // TODO: Implement create() method.
37
-    }
38
-
39
-    public function update($team)
40
-    {
41
-        // TODO: Implement update() method.
42
-    }
43
-
44
-    public function getByMatch($matchId)
45
-    {
46
-        return $this->teamMatch->where('match_id', '=', $matchId)->get();
47
-    }
17
+	private $teamMatch;
18
+
19
+	public function __construct(Teammatch $teamMatch)
20
+	{
21
+		$this->teamMatch = $teamMatch;
22
+	}
23
+
24
+	public function all()
25
+	{
26
+		// TODO: Implement all() method.
27
+	}
28
+
29
+	public function findById($id)
30
+	{
31
+		// TODO: Implement findById() method.
32
+	}
33
+
34
+	public function create($input)
35
+	{
36
+		// TODO: Implement create() method.
37
+	}
38
+
39
+	public function update($team)
40
+	{
41
+		// TODO: Implement update() method.
42
+	}
43
+
44
+	public function getByMatch($matchId)
45
+	{
46
+		return $this->teamMatch->where('match_id', '=', $matchId)->get();
47
+	}
48 48
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@
 block discarded – undo
12 12
 
13 13
 use GolfLeague\Storage\Team\TeamMatchesRepository;
14 14
 
15
-class EloquentTeamMatchesRepository implements TeamMatchesRepository
16
-{
15
+class EloquentTeamMatchesRepository implements TeamMatchesRepository {
17 16
     private $teamMatch;
18 17
 
19 18
     public function __construct(Teammatch $teamMatch)
Please login to merge, or discard this patch.
app/library/Storage/TeamRepository.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@
 block discarded – undo
4 4
 
5 5
 interface TeamRepository {
6 6
 
7
-    public function all();
8
-    public function findById($id);
9
-    public function findByYear($year);
10
-    public function create($input);
11
-    public function update($team);
7
+	public function all();
8
+	public function findById($id);
9
+	public function findByYear($year);
10
+	public function create($input);
11
+	public function update($team);
12 12
 }
13 13
\ No newline at end of file
Please login to merge, or discard this patch.