@@ -13,50 +13,50 @@ |
||
13 | 13 | * Multideminsional Array of Hole Numbers and scores * |
14 | 14 | **/ |
15 | 15 | |
16 | - public function __construct() |
|
17 | - { |
|
18 | - $this->today = Carbon::today()->toDateString(); |
|
19 | - } |
|
20 | - |
|
21 | - public function all() |
|
22 | - { |
|
23 | - //return Round::all(); |
|
24 | - |
|
25 | - $today = Carbon::today()->toDateString(); |
|
26 | - $rounds = Round::where('date', '<', $this->today) |
|
27 | - ->get(); |
|
28 | - return $rounds; |
|
29 | - } |
|
30 | - |
|
31 | - public function find($id) |
|
32 | - { |
|
33 | - return Round::find($id); |
|
34 | - } |
|
35 | - //Find Scores by Player Id |
|
36 | - |
|
37 | - public function findByPlayer($playerId) |
|
38 | - { |
|
39 | - return Round::with('player', 'holescores', 'course') |
|
40 | - ->where('player_id', '=', $playerId) |
|
41 | - ->where('date', '<', $this->today) |
|
42 | - ->get(); |
|
43 | - } |
|
44 | - |
|
45 | - public function findByMatch($matchId) |
|
46 | - { |
|
47 | - return Round::with('player', 'holescores')->where('match_id', '=', $matchId)->get(); |
|
48 | - } |
|
49 | - |
|
50 | - public function create($input) |
|
51 | - { |
|
52 | - return Round::create($input); |
|
53 | - } |
|
54 | - |
|
55 | - //pass this a round object and replace it in database |
|
56 | - public function update($round) |
|
57 | - { |
|
58 | - $updateRound = Round::find($round->id); |
|
59 | - $updateRound = $round; |
|
60 | - $updateRound->save(); |
|
61 | - } |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + $this->today = Carbon::today()->toDateString(); |
|
19 | + } |
|
20 | + |
|
21 | + public function all() |
|
22 | + { |
|
23 | + //return Round::all(); |
|
24 | + |
|
25 | + $today = Carbon::today()->toDateString(); |
|
26 | + $rounds = Round::where('date', '<', $this->today) |
|
27 | + ->get(); |
|
28 | + return $rounds; |
|
29 | + } |
|
30 | + |
|
31 | + public function find($id) |
|
32 | + { |
|
33 | + return Round::find($id); |
|
34 | + } |
|
35 | + //Find Scores by Player Id |
|
36 | + |
|
37 | + public function findByPlayer($playerId) |
|
38 | + { |
|
39 | + return Round::with('player', 'holescores', 'course') |
|
40 | + ->where('player_id', '=', $playerId) |
|
41 | + ->where('date', '<', $this->today) |
|
42 | + ->get(); |
|
43 | + } |
|
44 | + |
|
45 | + public function findByMatch($matchId) |
|
46 | + { |
|
47 | + return Round::with('player', 'holescores')->where('match_id', '=', $matchId)->get(); |
|
48 | + } |
|
49 | + |
|
50 | + public function create($input) |
|
51 | + { |
|
52 | + return Round::create($input); |
|
53 | + } |
|
54 | + |
|
55 | + //pass this a round object and replace it in database |
|
56 | + public function update($round) |
|
57 | + { |
|
58 | + $updateRound = Round::find($round->id); |
|
59 | + $updateRound = $round; |
|
60 | + $updateRound->save(); |
|
61 | + } |
|
62 | 62 | } |
@@ -3,8 +3,7 @@ |
||
3 | 3 | use \Round as Round; |
4 | 4 | use Carbon\Carbon; |
5 | 5 | |
6 | -class EloquentRoundRepository implements RoundRepository |
|
7 | -{ |
|
6 | +class EloquentRoundRepository implements RoundRepository { |
|
8 | 7 | /*Return Score collections that include: |
9 | 8 | * Player Name |
10 | 9 | * Date |
@@ -14,12 +14,12 @@ |
||
14 | 14 | class TournamentLeaderboardService |
15 | 15 | { |
16 | 16 | |
17 | - public function get($id) |
|
18 | - { |
|
19 | - $tournament = Tournament::find($id)->toArray(); |
|
20 | - $tournamentFactory= new TournamentFactory; |
|
21 | - $tournamentType = $tournamentFactory->create($tournament); |
|
22 | - return $tournamentType->getLeaderboard(); |
|
17 | + public function get($id) |
|
18 | + { |
|
19 | + $tournament = Tournament::find($id)->toArray(); |
|
20 | + $tournamentFactory= new TournamentFactory; |
|
21 | + $tournamentType = $tournamentFactory->create($tournament); |
|
22 | + return $tournamentType->getLeaderboard(); |
|
23 | 23 | |
24 | - } |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -17,7 +17,7 @@ |
||
17 | 17 | public function get($id) |
18 | 18 | { |
19 | 19 | $tournament = Tournament::find($id)->toArray(); |
20 | - $tournamentFactory= new TournamentFactory; |
|
20 | + $tournamentFactory = new TournamentFactory; |
|
21 | 21 | $tournamentType = $tournamentFactory->create($tournament); |
22 | 22 | return $tournamentType->getLeaderboard(); |
23 | 23 |
@@ -11,8 +11,7 @@ |
||
11 | 11 | use \Tournament as Tournament; |
12 | 12 | use GolfLeague\Tournament\TournamentFactory as TournamentFactory; |
13 | 13 | |
14 | -class TournamentLeaderboardService |
|
15 | -{ |
|
14 | +class TournamentLeaderboardService { |
|
16 | 15 | |
17 | 16 | public function get($id) |
18 | 17 | { |
@@ -9,31 +9,31 @@ |
||
9 | 9 | class TournamentService |
10 | 10 | { |
11 | 11 | |
12 | - public function create($input) |
|
13 | - { |
|
14 | - $tournament = new Tournament($input); |
|
15 | - $tournament->save(); |
|
16 | - |
|
17 | - foreach ($input['dates'] as $date){ |
|
18 | - $tournamentDate = new Tournamentdate(array('date' => $date)); |
|
19 | - $tournament->dates()->save($tournamentDate); |
|
20 | - } |
|
21 | - } |
|
22 | - |
|
23 | - public function getByMatchId($id) |
|
24 | - { |
|
25 | - //Get Match date and check tournament table for a tournament on that date |
|
26 | - $match = Match::find($id); |
|
27 | - $date = $match->date; |
|
12 | + public function create($input) |
|
13 | + { |
|
14 | + $tournament = new Tournament($input); |
|
15 | + $tournament->save(); |
|
16 | + |
|
17 | + foreach ($input['dates'] as $date){ |
|
18 | + $tournamentDate = new Tournamentdate(array('date' => $date)); |
|
19 | + $tournament->dates()->save($tournamentDate); |
|
20 | + } |
|
21 | + } |
|
22 | + |
|
23 | + public function getByMatchId($id) |
|
24 | + { |
|
25 | + //Get Match date and check tournament table for a tournament on that date |
|
26 | + $match = Match::find($id); |
|
27 | + $date = $match->date; |
|
28 | 28 | |
29 | - $tournamentDate = Tournamentdate::select('tournament_id')->where('date', '=', $date)->get(); |
|
30 | - return $tournamentDate; |
|
31 | - } |
|
32 | - |
|
33 | - public function get($id) |
|
34 | - { |
|
35 | - $tournament = Tournament::find($id); |
|
36 | - return $tournament; |
|
37 | - } |
|
29 | + $tournamentDate = Tournamentdate::select('tournament_id')->where('date', '=', $date)->get(); |
|
30 | + return $tournamentDate; |
|
31 | + } |
|
32 | + |
|
33 | + public function get($id) |
|
34 | + { |
|
35 | + $tournament = Tournament::find($id); |
|
36 | + return $tournament; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | $tournament = new Tournament($input); |
15 | 15 | $tournament->save(); |
16 | 16 | |
17 | - foreach ($input['dates'] as $date){ |
|
17 | + foreach ($input['dates'] as $date) { |
|
18 | 18 | $tournamentDate = new Tournamentdate(array('date' => $date)); |
19 | 19 | $tournament->dates()->save($tournamentDate); |
20 | 20 | } |
@@ -6,15 +6,14 @@ |
||
6 | 6 | use \Tournamentdate as Tournamentdate; |
7 | 7 | use Match as Match; |
8 | 8 | |
9 | -class TournamentService |
|
10 | -{ |
|
9 | +class TournamentService { |
|
11 | 10 | |
12 | 11 | public function create($input) |
13 | 12 | { |
14 | 13 | $tournament = new Tournament($input); |
15 | 14 | $tournament->save(); |
16 | 15 | |
17 | - foreach ($input['dates'] as $date){ |
|
16 | + foreach ($input['dates'] as $date) { |
|
18 | 17 | $tournamentDate = new Tournamentdate(array('date' => $date)); |
19 | 18 | $tournament->dates()->save($tournamentDate); |
20 | 19 | } |
@@ -14,71 +14,71 @@ |
||
14 | 14 | |
15 | 15 | class Net |
16 | 16 | { |
17 | - private $tournament; |
|
17 | + private $tournament; |
|
18 | 18 | |
19 | - public function __construct(array $tournament) |
|
20 | - { |
|
21 | - $this->tournament = Tournament::where('id', '=', $tournament['id'])->with('dates')->get(); |
|
22 | - } |
|
19 | + public function __construct(array $tournament) |
|
20 | + { |
|
21 | + $this->tournament = Tournament::where('id', '=', $tournament['id'])->with('dates')->get(); |
|
22 | + } |
|
23 | 23 | |
24 | - function get() |
|
25 | - { |
|
26 | - return 'im a net tournament with an ID of ' . $this->tournament->id; |
|
27 | - } |
|
24 | + function get() |
|
25 | + { |
|
26 | + return 'im a net tournament with an ID of ' . $this->tournament->id; |
|
27 | + } |
|
28 | 28 | |
29 | - function getLeaderboard() |
|
30 | - { |
|
31 | - //Quick and Dirty code for 2016 Tournament only |
|
32 | - // Will expand and extract later |
|
33 | - $matches = []; |
|
34 | - //for each date get the matchid that corresponds |
|
35 | - foreach($this->tournament as $tournament){ |
|
36 | - foreach($tournament->dates as $date){ |
|
37 | - $match = \Match::where('date', '=', $date->date)->get(); |
|
38 | - foreach ($match as $m){ |
|
39 | - $matchid = $m->id; |
|
40 | - } |
|
41 | - $matchRound = new MatchRound(); |
|
42 | - $leaderboardService = new LeaderboardService($matchRound); |
|
43 | - $current = $leaderboardService->calculate($matchid,'net'); |
|
44 | - $matches = array_merge($matches, $current); |
|
45 | - } |
|
46 | - } |
|
29 | + function getLeaderboard() |
|
30 | + { |
|
31 | + //Quick and Dirty code for 2016 Tournament only |
|
32 | + // Will expand and extract later |
|
33 | + $matches = []; |
|
34 | + //for each date get the matchid that corresponds |
|
35 | + foreach($this->tournament as $tournament){ |
|
36 | + foreach($tournament->dates as $date){ |
|
37 | + $match = \Match::where('date', '=', $date->date)->get(); |
|
38 | + foreach ($match as $m){ |
|
39 | + $matchid = $m->id; |
|
40 | + } |
|
41 | + $matchRound = new MatchRound(); |
|
42 | + $leaderboardService = new LeaderboardService($matchRound); |
|
43 | + $current = $leaderboardService->calculate($matchid,'net'); |
|
44 | + $matches = array_merge($matches, $current); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - $leaderboard = []; |
|
48 | + $leaderboard = []; |
|
49 | 49 | |
50 | - foreach($matches as $key=>$player){ |
|
51 | - $inArrayKey = $this->in_array_r($player['name'], $leaderboard, true); |
|
52 | - if($inArrayKey === false){ |
|
53 | - $leaderboard[$key]['name'] = $player['name']; |
|
54 | - $leaderboard[$key]['score'] = $player['score']; |
|
55 | - } |
|
56 | - else{ |
|
57 | - $score = $player['score'] + $leaderboard[$inArrayKey]['score']; |
|
58 | - $leaderboard[$inArrayKey]['score'] = $score; |
|
59 | - } |
|
60 | - } |
|
50 | + foreach($matches as $key=>$player){ |
|
51 | + $inArrayKey = $this->in_array_r($player['name'], $leaderboard, true); |
|
52 | + if($inArrayKey === false){ |
|
53 | + $leaderboard[$key]['name'] = $player['name']; |
|
54 | + $leaderboard[$key]['score'] = $player['score']; |
|
55 | + } |
|
56 | + else{ |
|
57 | + $score = $player['score'] + $leaderboard[$inArrayKey]['score']; |
|
58 | + $leaderboard[$inArrayKey]['score'] = $score; |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - $name = []; |
|
63 | - $score = []; |
|
64 | - foreach ($leaderboard as $key => $player) { |
|
65 | - $name[$key] = $player['name']; |
|
66 | - $score[$key] = $player['score']; |
|
67 | - } |
|
62 | + $name = []; |
|
63 | + $score = []; |
|
64 | + foreach ($leaderboard as $key => $player) { |
|
65 | + $name[$key] = $player['name']; |
|
66 | + $score[$key] = $player['score']; |
|
67 | + } |
|
68 | 68 | |
69 | - array_multisort($score, SORT_ASC, $name, SORT_ASC, $leaderboard); |
|
70 | - return $leaderboard; |
|
71 | - } |
|
69 | + array_multisort($score, SORT_ASC, $name, SORT_ASC, $leaderboard); |
|
70 | + return $leaderboard; |
|
71 | + } |
|
72 | 72 | |
73 | - function in_array_r($needle, $haystack, $strict = false) { |
|
74 | - foreach ($haystack as $key=>$item) { |
|
75 | - if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))) { |
|
76 | - return $key; |
|
77 | - } |
|
78 | - } |
|
73 | + function in_array_r($needle, $haystack, $strict = false) { |
|
74 | + foreach ($haystack as $key=>$item) { |
|
75 | + if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))) { |
|
76 | + return $key; |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - return false; |
|
81 | - } |
|
80 | + return false; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | function get() |
25 | 25 | { |
26 | - return 'im a net tournament with an ID of ' . $this->tournament->id; |
|
26 | + return 'im a net tournament with an ID of '.$this->tournament->id; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | function getLeaderboard() |
@@ -32,28 +32,28 @@ discard block |
||
32 | 32 | // Will expand and extract later |
33 | 33 | $matches = []; |
34 | 34 | //for each date get the matchid that corresponds |
35 | - foreach($this->tournament as $tournament){ |
|
36 | - foreach($tournament->dates as $date){ |
|
35 | + foreach ($this->tournament as $tournament) { |
|
36 | + foreach ($tournament->dates as $date) { |
|
37 | 37 | $match = \Match::where('date', '=', $date->date)->get(); |
38 | - foreach ($match as $m){ |
|
38 | + foreach ($match as $m) { |
|
39 | 39 | $matchid = $m->id; |
40 | 40 | } |
41 | 41 | $matchRound = new MatchRound(); |
42 | 42 | $leaderboardService = new LeaderboardService($matchRound); |
43 | - $current = $leaderboardService->calculate($matchid,'net'); |
|
43 | + $current = $leaderboardService->calculate($matchid, 'net'); |
|
44 | 44 | $matches = array_merge($matches, $current); |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | $leaderboard = []; |
49 | 49 | |
50 | - foreach($matches as $key=>$player){ |
|
51 | - $inArrayKey = $this->in_array_r($player['name'], $leaderboard, true); |
|
52 | - if($inArrayKey === false){ |
|
50 | + foreach ($matches as $key=>$player) { |
|
51 | + $inArrayKey = $this->in_array_r($player['name'], $leaderboard, true); |
|
52 | + if ($inArrayKey === false) { |
|
53 | 53 | $leaderboard[$key]['name'] = $player['name']; |
54 | 54 | $leaderboard[$key]['score'] = $player['score']; |
55 | 55 | } |
56 | - else{ |
|
56 | + else { |
|
57 | 57 | $score = $player['score'] + $leaderboard[$inArrayKey]['score']; |
58 | 58 | $leaderboard[$inArrayKey]['score'] = $score; |
59 | 59 | } |
@@ -12,8 +12,7 @@ discard block |
||
12 | 12 | use GolfLeague\Storage\MatchRound\EloquentMatchRoundRepository as MatchRound; |
13 | 13 | use GolfLeague\Services\LeaderboardService as LeaderboardService; |
14 | 14 | |
15 | -class Net |
|
16 | -{ |
|
15 | +class Net { |
|
17 | 16 | private $tournament; |
18 | 17 | |
19 | 18 | public function __construct(array $tournament) |
@@ -32,10 +31,10 @@ discard block |
||
32 | 31 | // Will expand and extract later |
33 | 32 | $matches = []; |
34 | 33 | //for each date get the matchid that corresponds |
35 | - foreach($this->tournament as $tournament){ |
|
36 | - foreach($tournament->dates as $date){ |
|
34 | + foreach($this->tournament as $tournament) { |
|
35 | + foreach($tournament->dates as $date) { |
|
37 | 36 | $match = \Match::where('date', '=', $date->date)->get(); |
38 | - foreach ($match as $m){ |
|
37 | + foreach ($match as $m) { |
|
39 | 38 | $matchid = $m->id; |
40 | 39 | } |
41 | 40 | $matchRound = new MatchRound(); |
@@ -47,13 +46,12 @@ discard block |
||
47 | 46 | |
48 | 47 | $leaderboard = []; |
49 | 48 | |
50 | - foreach($matches as $key=>$player){ |
|
49 | + foreach($matches as $key=>$player) { |
|
51 | 50 | $inArrayKey = $this->in_array_r($player['name'], $leaderboard, true); |
52 | - if($inArrayKey === false){ |
|
51 | + if($inArrayKey === false) { |
|
53 | 52 | $leaderboard[$key]['name'] = $player['name']; |
54 | 53 | $leaderboard[$key]['score'] = $player['score']; |
55 | - } |
|
56 | - else{ |
|
54 | + } else { |
|
57 | 55 | $score = $player['score'] + $leaderboard[$inArrayKey]['score']; |
58 | 56 | $leaderboard[$inArrayKey]['score'] = $score; |
59 | 57 | } |
@@ -70,7 +68,8 @@ discard block |
||
70 | 68 | return $leaderboard; |
71 | 69 | } |
72 | 70 | |
73 | - function in_array_r($needle, $haystack, $strict = false) { |
|
71 | + function in_array_r($needle, $haystack, $strict = false) |
|
72 | + { |
|
74 | 73 | foreach ($haystack as $key=>$item) { |
75 | 74 | if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))) { |
76 | 75 | return $key; |
@@ -13,11 +13,11 @@ |
||
13 | 13 | class TournamentFactory |
14 | 14 | { |
15 | 15 | |
16 | - public function create($tournament) |
|
17 | - { |
|
18 | - switch($tournament['format']){ |
|
19 | - case "net" || "Net": |
|
20 | - return new Net($tournament); |
|
21 | - } |
|
22 | - } |
|
16 | + public function create($tournament) |
|
17 | + { |
|
18 | + switch($tournament['format']){ |
|
19 | + case "net" || "Net": |
|
20 | + return new Net($tournament); |
|
21 | + } |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | public function create($tournament) |
17 | 17 | { |
18 | - switch($tournament['format']){ |
|
18 | + switch ($tournament['format']) { |
|
19 | 19 | case "net" || "Net": |
20 | 20 | return new Net($tournament); |
21 | 21 | } |
@@ -10,8 +10,7 @@ |
||
10 | 10 | |
11 | 11 | use GolfLeague\Tournament\Net as Net; |
12 | 12 | |
13 | -class TournamentFactory |
|
14 | -{ |
|
13 | +class TournamentFactory { |
|
15 | 14 | |
16 | 15 | public function create($tournament) |
17 | 16 | { |
@@ -11,58 +11,58 @@ discard block |
||
11 | 11 | |
12 | 12 | class LeagueStatisticsEloquent implements LeagueStatistics |
13 | 13 | { |
14 | - public function topFiveLowestScores() |
|
15 | - { |
|
16 | - return Round::with('player','course')->orderBy('score')->take(5)->get(); |
|
17 | - } |
|
18 | - public function topFiveLowestScoresByYear($year) |
|
19 | - { |
|
14 | + public function topFiveLowestScores() |
|
15 | + { |
|
16 | + return Round::with('player','course')->orderBy('score')->take(5)->get(); |
|
17 | + } |
|
18 | + public function topFiveLowestScoresByYear($year) |
|
19 | + { |
|
20 | 20 | $today = Carbon::today()->toDateString(); |
21 | 21 | $date1 = $year . '-01-01'; |
22 | - $date2 = $year . '-12-31'; |
|
23 | - return Round::with('player', 'course') |
|
24 | - ->where('match_id', '>', '0') |
|
25 | - ->where('date', '>=', $date1) |
|
26 | - ->where('date', '<=', $date2) |
|
22 | + $date2 = $year . '-12-31'; |
|
23 | + return Round::with('player', 'course') |
|
24 | + ->where('match_id', '>', '0') |
|
25 | + ->where('date', '>=', $date1) |
|
26 | + ->where('date', '<=', $date2) |
|
27 | 27 | ->where('date', '<=', $today) |
28 | - ->orderBy('score') |
|
29 | - ->take(5) |
|
30 | - ->get(); |
|
31 | - } |
|
32 | - public function topFiveScoringAverageByYear($year) |
|
33 | - { |
|
34 | - //Get players |
|
35 | - //For each player where match > 0 select scores and average them |
|
36 | - //Store in players array |
|
37 | - $date1 = $year . '-01-01'; |
|
38 | - $date2 = $year . '-12-31'; |
|
39 | - $players = Player::all(); |
|
40 | - $average = array(); |
|
41 | - $i = 0; |
|
42 | - foreach($players as $key => $player) { |
|
43 | - $rounds = Round::where('match_id', '>', '0') |
|
44 | - ->where('player_id', '=', $player->id) |
|
28 | + ->orderBy('score') |
|
29 | + ->take(5) |
|
30 | + ->get(); |
|
31 | + } |
|
32 | + public function topFiveScoringAverageByYear($year) |
|
33 | + { |
|
34 | + //Get players |
|
35 | + //For each player where match > 0 select scores and average them |
|
36 | + //Store in players array |
|
37 | + $date1 = $year . '-01-01'; |
|
38 | + $date2 = $year . '-12-31'; |
|
39 | + $players = Player::all(); |
|
40 | + $average = array(); |
|
41 | + $i = 0; |
|
42 | + foreach($players as $key => $player) { |
|
43 | + $rounds = Round::where('match_id', '>', '0') |
|
44 | + ->where('player_id', '=', $player->id) |
|
45 | 45 | ->where('score', '>', '30') |
46 | - ->where('date', '>=', $date1) |
|
47 | - ->where('date', '<=', $date2) |
|
48 | - ->get(); |
|
49 | - $scores = array(); |
|
46 | + ->where('date', '>=', $date1) |
|
47 | + ->where('date', '<=', $date2) |
|
48 | + ->get(); |
|
49 | + $scores = array(); |
|
50 | 50 | foreach($rounds as $round) { |
51 | 51 | $scores[] = $round->score; |
52 | 52 | } |
53 | - if(count($scores) > 0) { |
|
54 | - $average[$i]['average'] = round((array_sum($scores) / count($scores)) ,2); |
|
55 | - $average[$i]['player_id'] = $player->id; |
|
56 | - $average[$i]['name'] = $player->name; |
|
57 | - $average[$i]['rounds'] = count($scores); |
|
58 | - $i++; |
|
59 | - } |
|
60 | - } |
|
61 | - array_multisort($average); |
|
62 | - return $average; |
|
63 | - } |
|
64 | - public function topFiveNetScoresByYear($year) |
|
65 | - { |
|
53 | + if(count($scores) > 0) { |
|
54 | + $average[$i]['average'] = round((array_sum($scores) / count($scores)) ,2); |
|
55 | + $average[$i]['player_id'] = $player->id; |
|
56 | + $average[$i]['name'] = $player->name; |
|
57 | + $average[$i]['rounds'] = count($scores); |
|
58 | + $i++; |
|
59 | + } |
|
60 | + } |
|
61 | + array_multisort($average); |
|
62 | + return $average; |
|
63 | + } |
|
64 | + public function topFiveNetScoresByYear($year) |
|
65 | + { |
|
66 | 66 | $date1 = $year . '-01-01'; |
67 | 67 | $date2 = $year . '-12-31'; |
68 | 68 | |
@@ -70,28 +70,28 @@ discard block |
||
70 | 70 | ->where('created_at', '>=', $date1) |
71 | 71 | ->where('created_at', '<=', $date2) |
72 | 72 | ->orderBy('score')->take(5)->get(); |
73 | - } |
|
74 | - public function mostSkinsByYear($year) |
|
75 | - { |
|
76 | - $year = $year . '-01-01'; |
|
77 | - $players = Player::all(); |
|
78 | - $i = 0; |
|
79 | - $skinsCount = array(); |
|
80 | - foreach($players as $key => $player) { |
|
81 | - $skins = Skin::with('player','level') |
|
82 | - ->where('player_id', '=', $player->id) |
|
83 | - ->where('created_at', '>', $year) |
|
84 | - ->get(); |
|
85 | - if(count($skins) > 0) { |
|
86 | - $skinsCount[$i]['skins'] = $skins->count(); |
|
87 | - $skinsCount[$i]['name'] = $player->name; |
|
88 | - $i++; |
|
89 | - } |
|
90 | - } |
|
91 | - array_multisort($skinsCount, SORT_DESC); |
|
92 | - return $skinsCount; |
|
93 | - } |
|
94 | - public function totalEagles($year){ |
|
73 | + } |
|
74 | + public function mostSkinsByYear($year) |
|
75 | + { |
|
76 | + $year = $year . '-01-01'; |
|
77 | + $players = Player::all(); |
|
78 | + $i = 0; |
|
79 | + $skinsCount = array(); |
|
80 | + foreach($players as $key => $player) { |
|
81 | + $skins = Skin::with('player','level') |
|
82 | + ->where('player_id', '=', $player->id) |
|
83 | + ->where('created_at', '>', $year) |
|
84 | + ->get(); |
|
85 | + if(count($skins) > 0) { |
|
86 | + $skinsCount[$i]['skins'] = $skins->count(); |
|
87 | + $skinsCount[$i]['name'] = $player->name; |
|
88 | + $i++; |
|
89 | + } |
|
90 | + } |
|
91 | + array_multisort($skinsCount, SORT_DESC); |
|
92 | + return $skinsCount; |
|
93 | + } |
|
94 | + public function totalEagles($year){ |
|
95 | 95 | $date1 = $year . '-01-01'; |
96 | 96 | $date2 = $year . '-12-31'; |
97 | 97 | $holescores = Holescore::with('round.player','hole') |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | return $eagles; |
118 | 118 | } |
119 | - public function totalBirdies($year) |
|
119 | + public function totalBirdies($year) |
|
120 | 120 | { |
121 | 121 | $date1 = $year . '-01-01'; |
122 | 122 | $date2 = $year . '-12-31'; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | return $birds; |
144 | 144 | } |
145 | - public function totalPars($year) |
|
145 | + public function totalPars($year) |
|
146 | 146 | { |
147 | 147 | $year = $year . '-01-01'; |
148 | 148 | $holescores = Holescore::with('round.player','hole') |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | } |
167 | 167 | return $pars; |
168 | 168 | } |
169 | - public function totalBogeys($year) |
|
169 | + public function totalBogeys($year) |
|
170 | 170 | { |
171 | 171 | $year = $year . '-01-01'; |
172 | 172 | $holescores = Holescore::with('round.player','hole') |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | return $bogeys; |
192 | 192 | } |
193 | - public function totalDoubles($year) |
|
193 | + public function totalDoubles($year) |
|
194 | 194 | { |
195 | 195 | $year = $year . '-01-01'; |
196 | 196 | $holescores = Holescore::with('round.player','hole') |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } |
215 | 215 | return $doubles; |
216 | 216 | } |
217 | - public function totalOthers($year) |
|
217 | + public function totalOthers($year) |
|
218 | 218 | { |
219 | 219 | $year = $year . '-01-01'; |
220 | 220 | $holescores = Holescore::with('round.player','hole') |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | { |
14 | 14 | public function topFiveLowestScores() |
15 | 15 | { |
16 | - return Round::with('player','course')->orderBy('score')->take(5)->get(); |
|
16 | + return Round::with('player', 'course')->orderBy('score')->take(5)->get(); |
|
17 | 17 | } |
18 | 18 | public function topFiveLowestScoresByYear($year) |
19 | 19 | { |
20 | 20 | $today = Carbon::today()->toDateString(); |
21 | - $date1 = $year . '-01-01'; |
|
22 | - $date2 = $year . '-12-31'; |
|
21 | + $date1 = $year.'-01-01'; |
|
22 | + $date2 = $year.'-12-31'; |
|
23 | 23 | return Round::with('player', 'course') |
24 | 24 | ->where('match_id', '>', '0') |
25 | 25 | ->where('date', '>=', $date1) |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | //Get players |
35 | 35 | //For each player where match > 0 select scores and average them |
36 | 36 | //Store in players array |
37 | - $date1 = $year . '-01-01'; |
|
38 | - $date2 = $year . '-12-31'; |
|
37 | + $date1 = $year.'-01-01'; |
|
38 | + $date2 = $year.'-12-31'; |
|
39 | 39 | $players = Player::all(); |
40 | 40 | $average = array(); |
41 | 41 | $i = 0; |
42 | - foreach($players as $key => $player) { |
|
42 | + foreach ($players as $key => $player) { |
|
43 | 43 | $rounds = Round::where('match_id', '>', '0') |
44 | 44 | ->where('player_id', '=', $player->id) |
45 | 45 | ->where('score', '>', '30') |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | ->where('date', '<=', $date2) |
48 | 48 | ->get(); |
49 | 49 | $scores = array(); |
50 | - foreach($rounds as $round) { |
|
50 | + foreach ($rounds as $round) { |
|
51 | 51 | $scores[] = $round->score; |
52 | 52 | } |
53 | - if(count($scores) > 0) { |
|
54 | - $average[$i]['average'] = round((array_sum($scores) / count($scores)) ,2); |
|
53 | + if (count($scores) > 0) { |
|
54 | + $average[$i]['average'] = round((array_sum($scores) / count($scores)), 2); |
|
55 | 55 | $average[$i]['player_id'] = $player->id; |
56 | 56 | $average[$i]['name'] = $player->name; |
57 | 57 | $average[$i]['rounds'] = count($scores); |
@@ -63,26 +63,26 @@ discard block |
||
63 | 63 | } |
64 | 64 | public function topFiveNetScoresByYear($year) |
65 | 65 | { |
66 | - $date1 = $year . '-01-01'; |
|
67 | - $date2 = $year . '-12-31'; |
|
66 | + $date1 = $year.'-01-01'; |
|
67 | + $date2 = $year.'-12-31'; |
|
68 | 68 | |
69 | - return Netwinner::with('player','match','match.course') |
|
69 | + return Netwinner::with('player', 'match', 'match.course') |
|
70 | 70 | ->where('created_at', '>=', $date1) |
71 | 71 | ->where('created_at', '<=', $date2) |
72 | 72 | ->orderBy('score')->take(5)->get(); |
73 | 73 | } |
74 | 74 | public function mostSkinsByYear($year) |
75 | 75 | { |
76 | - $year = $year . '-01-01'; |
|
76 | + $year = $year.'-01-01'; |
|
77 | 77 | $players = Player::all(); |
78 | 78 | $i = 0; |
79 | 79 | $skinsCount = array(); |
80 | - foreach($players as $key => $player) { |
|
81 | - $skins = Skin::with('player','level') |
|
80 | + foreach ($players as $key => $player) { |
|
81 | + $skins = Skin::with('player', 'level') |
|
82 | 82 | ->where('player_id', '=', $player->id) |
83 | 83 | ->where('created_at', '>', $year) |
84 | 84 | ->get(); |
85 | - if(count($skins) > 0) { |
|
85 | + if (count($skins) > 0) { |
|
86 | 86 | $skinsCount[$i]['skins'] = $skins->count(); |
87 | 87 | $skinsCount[$i]['name'] = $player->name; |
88 | 88 | $i++; |
@@ -91,92 +91,92 @@ discard block |
||
91 | 91 | array_multisort($skinsCount, SORT_DESC); |
92 | 92 | return $skinsCount; |
93 | 93 | } |
94 | - public function totalEagles($year){ |
|
95 | - $date1 = $year . '-01-01'; |
|
96 | - $date2 = $year . '-12-31'; |
|
97 | - $holescores = Holescore::with('round.player','hole') |
|
94 | + public function totalEagles($year) { |
|
95 | + $date1 = $year.'-01-01'; |
|
96 | + $date2 = $year.'-12-31'; |
|
97 | + $holescores = Holescore::with('round.player', 'hole') |
|
98 | 98 | ->where('created_at', '>=', $date1) |
99 | 99 | ->where('created_at', '<=', $date2) |
100 | 100 | ->get(); |
101 | 101 | $allEagles = array(); |
102 | - foreach($holescores as $key => $holescore) { |
|
103 | - if($holescore['round']['match_id'] != null){ |
|
104 | - if( ($holescore['hole']['par'] - $holescore['score']) === 2) { |
|
105 | - $allEagles[]= $holescore['round']['player']['name']; |
|
102 | + foreach ($holescores as $key => $holescore) { |
|
103 | + if ($holescore['round']['match_id'] != null) { |
|
104 | + if (($holescore['hole']['par'] - $holescore['score']) === 2) { |
|
105 | + $allEagles[] = $holescore['round']['player']['name']; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
109 | - $i =0; |
|
109 | + $i = 0; |
|
110 | 110 | $newArray = array_count_values($allEagles); |
111 | 111 | $eagles = array(); |
112 | 112 | foreach ($newArray as $key => $value) { |
113 | 113 | $eagles[$i]['name'] = $key; |
114 | - $eagles[$i]['eagles'] =$value; |
|
114 | + $eagles[$i]['eagles'] = $value; |
|
115 | 115 | $i++; |
116 | 116 | } |
117 | 117 | return $eagles; |
118 | 118 | } |
119 | 119 | public function totalBirdies($year) |
120 | 120 | { |
121 | - $date1 = $year . '-01-01'; |
|
122 | - $date2 = $year . '-12-31'; |
|
123 | - $holescores = Holescore::with('round.player','hole') |
|
121 | + $date1 = $year.'-01-01'; |
|
122 | + $date2 = $year.'-12-31'; |
|
123 | + $holescores = Holescore::with('round.player', 'hole') |
|
124 | 124 | ->where('created_at', '>=', $date1) |
125 | 125 | ->where('created_at', '<=', $date2) |
126 | 126 | ->get(); |
127 | 127 | $allBirdies = array(); |
128 | - foreach($holescores as $key => $holescore) { |
|
129 | - if($holescore['round']['match_id'] != null){ |
|
130 | - if( ($holescore['hole']['par'] - $holescore['score']) === 1) { |
|
131 | - $allBirdies[]= $holescore['round']['player']['name']; |
|
128 | + foreach ($holescores as $key => $holescore) { |
|
129 | + if ($holescore['round']['match_id'] != null) { |
|
130 | + if (($holescore['hole']['par'] - $holescore['score']) === 1) { |
|
131 | + $allBirdies[] = $holescore['round']['player']['name']; |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | - $i =0; |
|
135 | + $i = 0; |
|
136 | 136 | $newArray = array_count_values($allBirdies); |
137 | 137 | $birds = array(); |
138 | 138 | foreach ($newArray as $key => $value) { |
139 | 139 | $birds[$i]['name'] = $key; |
140 | - $birds[$i]['birds'] =$value; |
|
140 | + $birds[$i]['birds'] = $value; |
|
141 | 141 | $i++; |
142 | 142 | } |
143 | 143 | return $birds; |
144 | 144 | } |
145 | 145 | public function totalPars($year) |
146 | 146 | { |
147 | - $year = $year . '-01-01'; |
|
148 | - $holescores = Holescore::with('round.player','hole') |
|
147 | + $year = $year.'-01-01'; |
|
148 | + $holescores = Holescore::with('round.player', 'hole') |
|
149 | 149 | ->where('created_at', '>', $year) |
150 | 150 | ->get(); |
151 | 151 | $allPars = array(); |
152 | - foreach($holescores as $key => $holescore) { |
|
153 | - if($holescore['round']['match_id'] != null){ |
|
154 | - if( ($holescore['hole']['par'] - $holescore['score']) === 0) { |
|
155 | - $allPars[]= $holescore['round']['player']['name']; |
|
152 | + foreach ($holescores as $key => $holescore) { |
|
153 | + if ($holescore['round']['match_id'] != null) { |
|
154 | + if (($holescore['hole']['par'] - $holescore['score']) === 0) { |
|
155 | + $allPars[] = $holescore['round']['player']['name']; |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
159 | - $i =0; |
|
159 | + $i = 0; |
|
160 | 160 | $newArray = array_count_values($allPars); |
161 | 161 | $pars = array(); |
162 | 162 | foreach ($newArray as $key => $value) { |
163 | 163 | $pars[$i]['name'] = $key; |
164 | - $pars[$i]['pars'] =$value; |
|
164 | + $pars[$i]['pars'] = $value; |
|
165 | 165 | $i++; |
166 | 166 | } |
167 | 167 | return $pars; |
168 | 168 | } |
169 | 169 | public function totalBogeys($year) |
170 | 170 | { |
171 | - $year = $year . '-01-01'; |
|
172 | - $holescores = Holescore::with('round.player','hole') |
|
171 | + $year = $year.'-01-01'; |
|
172 | + $holescores = Holescore::with('round.player', 'hole') |
|
173 | 173 | ->where('created_at', '>', $year) |
174 | 174 | ->get(); |
175 | 175 | $allBogeys = array(); |
176 | - foreach($holescores as $key => $holescore) { |
|
177 | - if($holescore['round']['match_id'] != null){ |
|
178 | - if( ($holescore['score'] - $holescore['hole']['par']) === 1) { |
|
179 | - $allBogeys[]= $holescore['round']['player']['name']; |
|
176 | + foreach ($holescores as $key => $holescore) { |
|
177 | + if ($holescore['round']['match_id'] != null) { |
|
178 | + if (($holescore['score'] - $holescore['hole']['par']) === 1) { |
|
179 | + $allBogeys[] = $holescore['round']['player']['name']; |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
@@ -185,22 +185,22 @@ discard block |
||
185 | 185 | $bogeys = array(); |
186 | 186 | foreach ($newArray as $key => $value) { |
187 | 187 | $bogeys[$i]['name'] = $key; |
188 | - $bogeys[$i]['bogeys'] =$value; |
|
188 | + $bogeys[$i]['bogeys'] = $value; |
|
189 | 189 | $i++; |
190 | 190 | } |
191 | 191 | return $bogeys; |
192 | 192 | } |
193 | 193 | public function totalDoubles($year) |
194 | 194 | { |
195 | - $year = $year . '-01-01'; |
|
196 | - $holescores = Holescore::with('round.player','hole') |
|
195 | + $year = $year.'-01-01'; |
|
196 | + $holescores = Holescore::with('round.player', 'hole') |
|
197 | 197 | ->where('created_at', '>', $year) |
198 | 198 | ->get(); |
199 | 199 | $allDoubles = array(); |
200 | - foreach($holescores as $key => $holescore) { |
|
201 | - if($holescore['round']['match_id'] != null){ |
|
202 | - if( ($holescore['score'] - $holescore['hole']['par']) === 2) { |
|
203 | - $allDoubles[]= $holescore['round']['player']['name']; |
|
200 | + foreach ($holescores as $key => $holescore) { |
|
201 | + if ($holescore['round']['match_id'] != null) { |
|
202 | + if (($holescore['score'] - $holescore['hole']['par']) === 2) { |
|
203 | + $allDoubles[] = $holescore['round']['player']['name']; |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
@@ -209,22 +209,22 @@ discard block |
||
209 | 209 | $doubles = array(); |
210 | 210 | foreach ($newArray as $key => $value) { |
211 | 211 | $doubles[$i]['name'] = $key; |
212 | - $doubles[$i]['doubles'] =$value; |
|
212 | + $doubles[$i]['doubles'] = $value; |
|
213 | 213 | $i++; |
214 | 214 | } |
215 | 215 | return $doubles; |
216 | 216 | } |
217 | 217 | public function totalOthers($year) |
218 | 218 | { |
219 | - $year = $year . '-01-01'; |
|
220 | - $holescores = Holescore::with('round.player','hole') |
|
219 | + $year = $year.'-01-01'; |
|
220 | + $holescores = Holescore::with('round.player', 'hole') |
|
221 | 221 | ->where('created_at', '>', $year) |
222 | 222 | ->get(); |
223 | 223 | $allOthers = array(); |
224 | - foreach($holescores as $key => $holescore) { |
|
225 | - if($holescore['round']['match_id'] != null){ |
|
226 | - if( ($holescore['score'] - $holescore['hole']['par']) > 2) { |
|
227 | - $allOthers[]= $holescore['round']['player']['name']; |
|
224 | + foreach ($holescores as $key => $holescore) { |
|
225 | + if ($holescore['round']['match_id'] != null) { |
|
226 | + if (($holescore['score'] - $holescore['hole']['par']) > 2) { |
|
227 | + $allOthers[] = $holescore['round']['player']['name']; |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $others = array(); |
234 | 234 | foreach ($newArray as $key => $value) { |
235 | 235 | $others[$i]['name'] = $key; |
236 | - $others[$i]['others'] =$value; |
|
236 | + $others[$i]['others'] = $value; |
|
237 | 237 | $i++; |
238 | 238 | } |
239 | 239 | return $others; |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | //for each round get match handicap |
250 | 250 | $rounds->map(function($round) |
251 | 251 | { |
252 | - $playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get(); |
|
253 | - foreach($playerMatch as $player){ |
|
252 | + $playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id', '=', $round->match_id)->get(); |
|
253 | + foreach ($playerMatch as $player) { |
|
254 | 254 | $handicap = $player['pivot']['handicap']; |
255 | 255 | $round->handicap = $handicap; |
256 | 256 | } |
@@ -276,15 +276,15 @@ discard block |
||
276 | 276 | return $rounds; |
277 | 277 | |
278 | 278 | } |
279 | - public function netScoresByPlayerTop($playerId,$top) |
|
279 | + public function netScoresByPlayerTop($playerId, $top) |
|
280 | 280 | { |
281 | 281 | $netScores = $this->netScoresByPlayer($playerId); |
282 | 282 | return $netScores->take($top); |
283 | 283 | } |
284 | 284 | public function netScoresByPlayerYear($playerId, $year) |
285 | 285 | { |
286 | - $date1 = $year . '-12-31'; |
|
287 | - $date2 = $year . '-01-01'; |
|
286 | + $date1 = $year.'-12-31'; |
|
287 | + $date2 = $year.'-01-01'; |
|
288 | 288 | //$date2 = $date1 - 1; |
289 | 289 | //$date2 .= '-01-01'; |
290 | 290 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | $rounds = Round::with('player') |
294 | 294 | ->where('player_id', '=', $playerId) |
295 | 295 | ->where('date', '<', $date1) |
296 | - ->where('date','>', $date2) |
|
296 | + ->where('date', '>', $date2) |
|
297 | 297 | ->whereNotNull('match_id')->get(); |
298 | 298 | |
299 | 299 | //for each round get match handicap |
300 | 300 | $rounds->map(function($round) |
301 | 301 | { |
302 | - $playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get(); |
|
303 | - foreach($playerMatch as $player){ |
|
302 | + $playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id', '=', $round->match_id)->get(); |
|
303 | + foreach ($playerMatch as $player) { |
|
304 | 304 | $handicap = $player['pivot']['handicap']; |
305 | 305 | $round->handicap = $handicap; |
306 | 306 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | return $rounds; |
327 | 327 | } |
328 | - public function netScoresByPlayerTopYear($playerId,$top, $year) |
|
328 | + public function netScoresByPlayerTopYear($playerId, $top, $year) |
|
329 | 329 | { |
330 | 330 | $netScores = $this->netScoresByPlayerYear($playerId, $year); |
331 | 331 | return $netScores->take($top); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $players = Player::all(); |
338 | 338 | |
339 | 339 | $netScores = new \Illuminate\Support\Collection(); |
340 | - foreach($players as $player){ |
|
340 | + foreach ($players as $player) { |
|
341 | 341 | $netScores->push($this->netScoresByPlayer($player->id)); |
342 | 342 | } |
343 | 343 | return $netScores; |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | $players = Player::all(); |
350 | 350 | |
351 | 351 | $netScores = new \Illuminate\Support\Collection(); |
352 | - foreach($players as $player){ |
|
352 | + foreach ($players as $player) { |
|
353 | 353 | $netScore = $this->netScoresByPlayerTop($player->id, $number); |
354 | - if(!$netScore->isEmpty()){ |
|
354 | + if ( ! $netScore->isEmpty()) { |
|
355 | 355 | $netScores->push($netScore); |
356 | 356 | } |
357 | 357 | } |
@@ -364,20 +364,20 @@ discard block |
||
364 | 364 | $players = Player::all(); |
365 | 365 | |
366 | 366 | $netScores = new \Illuminate\Support\Collection(); |
367 | - foreach($players as $player){ |
|
368 | - $netScores->push($this->netScoresByPlayerYear($player->id,$year)); |
|
367 | + foreach ($players as $player) { |
|
368 | + $netScores->push($this->netScoresByPlayerYear($player->id, $year)); |
|
369 | 369 | } |
370 | 370 | return $netScores; |
371 | 371 | } |
372 | - public function netScoresLeagueTopYear($top,$year) |
|
372 | + public function netScoresLeagueTopYear($top, $year) |
|
373 | 373 | { |
374 | 374 | //get players |
375 | 375 | $players = Player::all(); |
376 | 376 | |
377 | 377 | $netScores = new \Illuminate\Support\Collection(); |
378 | - foreach($players as $player){ |
|
378 | + foreach ($players as $player) { |
|
379 | 379 | $netScore = $this->netScoresByPlayerTopYear($player->id, $top, $year); |
380 | - if(!$netScore->isEmpty()){ |
|
380 | + if ( ! $netScore->isEmpty()) { |
|
381 | 381 | $netScores->push($netScore); |
382 | 382 | } |
383 | 383 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $players = Player::all(); |
392 | 392 | |
393 | 393 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
394 | - foreach($players as $player){ |
|
394 | + foreach ($players as $player) { |
|
395 | 395 | $cumulativeNetScores->push($this->netCumulativeByPlayer($player->id)); |
396 | 396 | } |
397 | 397 | return $cumulativeNetScores; |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | $players = Player::all(); |
403 | 403 | |
404 | 404 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
405 | - foreach($players as $player){ |
|
405 | + foreach ($players as $player) { |
|
406 | 406 | $netScore = $this->netCumulativeByPlayerTop($player->id, $top); |
407 | - if($netScore->isEmpty() == false){ |
|
407 | + if ($netScore->isEmpty() == false) { |
|
408 | 408 | $cumulativeNetScores->push($netScore); |
409 | 409 | } |
410 | 410 | } |
@@ -414,9 +414,9 @@ discard block |
||
414 | 414 | public function netCumulativeByPlayer($playerId) |
415 | 415 | { |
416 | 416 | $netScores = $this->netScoresByPlayer($playerId); |
417 | - $cumulativeNet= new \Illuminate\Support\Collection(); |
|
417 | + $cumulativeNet = new \Illuminate\Support\Collection(); |
|
418 | 418 | |
419 | - if($netScores->count() > 0){ |
|
419 | + if ($netScores->count() > 0) { |
|
420 | 420 | $netScore = $netScores->first(); |
421 | 421 | |
422 | 422 | $totalNetScore = $netScores->sum('netScore'); |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | public function netCumulativeByPlayerTop($playerId, $top) |
431 | 431 | { |
432 | 432 | $netScores = $this->netScoresByPlayerTop($playerId, $top); |
433 | - $cumulativeNet= new \Illuminate\Support\Collection(); |
|
433 | + $cumulativeNet = new \Illuminate\Support\Collection(); |
|
434 | 434 | |
435 | - if($netScores->count() > 0){ |
|
435 | + if ($netScores->count() > 0) { |
|
436 | 436 | $netScore = $netScores->first(); |
437 | 437 | |
438 | 438 | $totalNetScore = $netScores->sum('netScore'); |
@@ -449,32 +449,32 @@ discard block |
||
449 | 449 | $players = Player::all(); |
450 | 450 | |
451 | 451 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
452 | - foreach($players as $player){ |
|
453 | - $cumulativeNetScores->push($this->netCumulativeByPlayerYear($player->id,$year)); |
|
452 | + foreach ($players as $player) { |
|
453 | + $cumulativeNetScores->push($this->netCumulativeByPlayerYear($player->id, $year)); |
|
454 | 454 | } |
455 | 455 | return $cumulativeNetScores; |
456 | 456 | } |
457 | - public function netCumulativeTopYear($top,$year) |
|
457 | + public function netCumulativeTopYear($top, $year) |
|
458 | 458 | { |
459 | 459 | //get players |
460 | 460 | $players = Player::all(); |
461 | 461 | |
462 | 462 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
463 | - foreach($players as $player){ |
|
463 | + foreach ($players as $player) { |
|
464 | 464 | $netScore = $this->netCumulativeByPlayerTopYear($player->id, $top, $year); |
465 | - if($netScore->isEmpty() == false){ |
|
465 | + if ($netScore->isEmpty() == false) { |
|
466 | 466 | $cumulativeNetScores->push($netScore); |
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
470 | 470 | return $cumulativeNetScores; |
471 | 471 | } |
472 | - public function netCumulativeByPlayerYear($playerId,$year) |
|
472 | + public function netCumulativeByPlayerYear($playerId, $year) |
|
473 | 473 | { |
474 | 474 | $netScores = $this->netScoresByPlayerYear($playerId, $year); |
475 | - $cumulativeNet= new \Illuminate\Support\Collection(); |
|
475 | + $cumulativeNet = new \Illuminate\Support\Collection(); |
|
476 | 476 | |
477 | - if($netScores->count() > 0){ |
|
477 | + if ($netScores->count() > 0) { |
|
478 | 478 | $netScore = $netScores->first(); |
479 | 479 | |
480 | 480 | $totalNetScore = $netScores->sum('netScore'); |
@@ -485,12 +485,12 @@ discard block |
||
485 | 485 | |
486 | 486 | return $cumulativeNet; |
487 | 487 | } |
488 | - public function netCumulativeByPlayerTopYear($playerId,$top,$year) |
|
488 | + public function netCumulativeByPlayerTopYear($playerId, $top, $year) |
|
489 | 489 | { |
490 | 490 | $netScores = $this->netScoresByPlayerTopYear($playerId, $top, $year); |
491 | - $cumulativeNet= new \Illuminate\Support\Collection(); |
|
491 | + $cumulativeNet = new \Illuminate\Support\Collection(); |
|
492 | 492 | |
493 | - if($netScores->count() > 0){ |
|
493 | + if ($netScores->count() > 0) { |
|
494 | 494 | $netScore = $netScores->first(); |
495 | 495 | |
496 | 496 | $totalNetScore = $netScores->sum('netScore'); |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | use \Match; |
10 | 10 | use Carbon\Carbon; |
11 | 11 | |
12 | -class LeagueStatisticsEloquent implements LeagueStatistics |
|
13 | -{ |
|
12 | +class LeagueStatisticsEloquent implements LeagueStatistics { |
|
14 | 13 | public function topFiveLowestScores() |
15 | 14 | { |
16 | 15 | return Round::with('player','course')->orderBy('score')->take(5)->get(); |
@@ -91,7 +90,8 @@ discard block |
||
91 | 90 | array_multisort($skinsCount, SORT_DESC); |
92 | 91 | return $skinsCount; |
93 | 92 | } |
94 | - public function totalEagles($year){ |
|
93 | + public function totalEagles($year) |
|
94 | + { |
|
95 | 95 | $date1 = $year . '-01-01'; |
96 | 96 | $date2 = $year . '-12-31'; |
97 | 97 | $holescores = Holescore::with('round.player','hole') |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ->get(); |
101 | 101 | $allEagles = array(); |
102 | 102 | foreach($holescores as $key => $holescore) { |
103 | - if($holescore['round']['match_id'] != null){ |
|
103 | + if($holescore['round']['match_id'] != null) { |
|
104 | 104 | if( ($holescore['hole']['par'] - $holescore['score']) === 2) { |
105 | 105 | $allEagles[]= $holescore['round']['player']['name']; |
106 | 106 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | return $eagles; |
118 | 118 | } |
119 | 119 | public function totalBirdies($year) |
120 | - { |
|
120 | + { |
|
121 | 121 | $date1 = $year . '-01-01'; |
122 | 122 | $date2 = $year . '-12-31'; |
123 | 123 | $holescores = Holescore::with('round.player','hole') |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | ->get(); |
127 | 127 | $allBirdies = array(); |
128 | 128 | foreach($holescores as $key => $holescore) { |
129 | - if($holescore['round']['match_id'] != null){ |
|
129 | + if($holescore['round']['match_id'] != null) { |
|
130 | 130 | if( ($holescore['hole']['par'] - $holescore['score']) === 1) { |
131 | 131 | $allBirdies[]= $holescore['round']['player']['name']; |
132 | 132 | } |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | return $birds; |
144 | 144 | } |
145 | 145 | public function totalPars($year) |
146 | - { |
|
146 | + { |
|
147 | 147 | $year = $year . '-01-01'; |
148 | 148 | $holescores = Holescore::with('round.player','hole') |
149 | 149 | ->where('created_at', '>', $year) |
150 | 150 | ->get(); |
151 | 151 | $allPars = array(); |
152 | 152 | foreach($holescores as $key => $holescore) { |
153 | - if($holescore['round']['match_id'] != null){ |
|
153 | + if($holescore['round']['match_id'] != null) { |
|
154 | 154 | if( ($holescore['hole']['par'] - $holescore['score']) === 0) { |
155 | 155 | $allPars[]= $holescore['round']['player']['name']; |
156 | 156 | } |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | return $pars; |
168 | 168 | } |
169 | 169 | public function totalBogeys($year) |
170 | - { |
|
170 | + { |
|
171 | 171 | $year = $year . '-01-01'; |
172 | 172 | $holescores = Holescore::with('round.player','hole') |
173 | 173 | ->where('created_at', '>', $year) |
174 | 174 | ->get(); |
175 | 175 | $allBogeys = array(); |
176 | 176 | foreach($holescores as $key => $holescore) { |
177 | - if($holescore['round']['match_id'] != null){ |
|
177 | + if($holescore['round']['match_id'] != null) { |
|
178 | 178 | if( ($holescore['score'] - $holescore['hole']['par']) === 1) { |
179 | 179 | $allBogeys[]= $holescore['round']['player']['name']; |
180 | 180 | } |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | return $bogeys; |
192 | 192 | } |
193 | 193 | public function totalDoubles($year) |
194 | - { |
|
194 | + { |
|
195 | 195 | $year = $year . '-01-01'; |
196 | 196 | $holescores = Holescore::with('round.player','hole') |
197 | 197 | ->where('created_at', '>', $year) |
198 | 198 | ->get(); |
199 | 199 | $allDoubles = array(); |
200 | 200 | foreach($holescores as $key => $holescore) { |
201 | - if($holescore['round']['match_id'] != null){ |
|
201 | + if($holescore['round']['match_id'] != null) { |
|
202 | 202 | if( ($holescore['score'] - $holescore['hole']['par']) === 2) { |
203 | 203 | $allDoubles[]= $holescore['round']['player']['name']; |
204 | 204 | } |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | return $doubles; |
216 | 216 | } |
217 | 217 | public function totalOthers($year) |
218 | - { |
|
218 | + { |
|
219 | 219 | $year = $year . '-01-01'; |
220 | 220 | $holescores = Holescore::with('round.player','hole') |
221 | 221 | ->where('created_at', '>', $year) |
222 | 222 | ->get(); |
223 | 223 | $allOthers = array(); |
224 | 224 | foreach($holescores as $key => $holescore) { |
225 | - if($holescore['round']['match_id'] != null){ |
|
225 | + if($holescore['round']['match_id'] != null) { |
|
226 | 226 | if( ($holescore['score'] - $holescore['hole']['par']) > 2) { |
227 | 227 | $allOthers[]= $holescore['round']['player']['name']; |
228 | 228 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $rounds->map(function($round) |
251 | 251 | { |
252 | 252 | $playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get(); |
253 | - foreach($playerMatch as $player){ |
|
253 | + foreach($playerMatch as $player) { |
|
254 | 254 | $handicap = $player['pivot']['handicap']; |
255 | 255 | $round->handicap = $handicap; |
256 | 256 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $rounds->map(function($round) |
301 | 301 | { |
302 | 302 | $playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get(); |
303 | - foreach($playerMatch as $player){ |
|
303 | + foreach($playerMatch as $player) { |
|
304 | 304 | $handicap = $player['pivot']['handicap']; |
305 | 305 | $round->handicap = $handicap; |
306 | 306 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $players = Player::all(); |
338 | 338 | |
339 | 339 | $netScores = new \Illuminate\Support\Collection(); |
340 | - foreach($players as $player){ |
|
340 | + foreach($players as $player) { |
|
341 | 341 | $netScores->push($this->netScoresByPlayer($player->id)); |
342 | 342 | } |
343 | 343 | return $netScores; |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | $players = Player::all(); |
350 | 350 | |
351 | 351 | $netScores = new \Illuminate\Support\Collection(); |
352 | - foreach($players as $player){ |
|
352 | + foreach($players as $player) { |
|
353 | 353 | $netScore = $this->netScoresByPlayerTop($player->id, $number); |
354 | - if(!$netScore->isEmpty()){ |
|
354 | + if(!$netScore->isEmpty()) { |
|
355 | 355 | $netScores->push($netScore); |
356 | 356 | } |
357 | 357 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $players = Player::all(); |
365 | 365 | |
366 | 366 | $netScores = new \Illuminate\Support\Collection(); |
367 | - foreach($players as $player){ |
|
367 | + foreach($players as $player) { |
|
368 | 368 | $netScores->push($this->netScoresByPlayerYear($player->id,$year)); |
369 | 369 | } |
370 | 370 | return $netScores; |
@@ -375,9 +375,9 @@ discard block |
||
375 | 375 | $players = Player::all(); |
376 | 376 | |
377 | 377 | $netScores = new \Illuminate\Support\Collection(); |
378 | - foreach($players as $player){ |
|
378 | + foreach($players as $player) { |
|
379 | 379 | $netScore = $this->netScoresByPlayerTopYear($player->id, $top, $year); |
380 | - if(!$netScore->isEmpty()){ |
|
380 | + if(!$netScore->isEmpty()) { |
|
381 | 381 | $netScores->push($netScore); |
382 | 382 | } |
383 | 383 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $players = Player::all(); |
392 | 392 | |
393 | 393 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
394 | - foreach($players as $player){ |
|
394 | + foreach($players as $player) { |
|
395 | 395 | $cumulativeNetScores->push($this->netCumulativeByPlayer($player->id)); |
396 | 396 | } |
397 | 397 | return $cumulativeNetScores; |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | $players = Player::all(); |
403 | 403 | |
404 | 404 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
405 | - foreach($players as $player){ |
|
405 | + foreach($players as $player) { |
|
406 | 406 | $netScore = $this->netCumulativeByPlayerTop($player->id, $top); |
407 | - if($netScore->isEmpty() == false){ |
|
407 | + if($netScore->isEmpty() == false) { |
|
408 | 408 | $cumulativeNetScores->push($netScore); |
409 | 409 | } |
410 | 410 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | $netScores = $this->netScoresByPlayer($playerId); |
417 | 417 | $cumulativeNet= new \Illuminate\Support\Collection(); |
418 | 418 | |
419 | - if($netScores->count() > 0){ |
|
419 | + if($netScores->count() > 0) { |
|
420 | 420 | $netScore = $netScores->first(); |
421 | 421 | |
422 | 422 | $totalNetScore = $netScores->sum('netScore'); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $netScores = $this->netScoresByPlayerTop($playerId, $top); |
433 | 433 | $cumulativeNet= new \Illuminate\Support\Collection(); |
434 | 434 | |
435 | - if($netScores->count() > 0){ |
|
435 | + if($netScores->count() > 0) { |
|
436 | 436 | $netScore = $netScores->first(); |
437 | 437 | |
438 | 438 | $totalNetScore = $netScores->sum('netScore'); |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $players = Player::all(); |
450 | 450 | |
451 | 451 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
452 | - foreach($players as $player){ |
|
452 | + foreach($players as $player) { |
|
453 | 453 | $cumulativeNetScores->push($this->netCumulativeByPlayerYear($player->id,$year)); |
454 | 454 | } |
455 | 455 | return $cumulativeNetScores; |
@@ -460,9 +460,9 @@ discard block |
||
460 | 460 | $players = Player::all(); |
461 | 461 | |
462 | 462 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
463 | - foreach($players as $player){ |
|
463 | + foreach($players as $player) { |
|
464 | 464 | $netScore = $this->netCumulativeByPlayerTopYear($player->id, $top, $year); |
465 | - if($netScore->isEmpty() == false){ |
|
465 | + if($netScore->isEmpty() == false) { |
|
466 | 466 | $cumulativeNetScores->push($netScore); |
467 | 467 | } |
468 | 468 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | $netScores = $this->netScoresByPlayerYear($playerId, $year); |
475 | 475 | $cumulativeNet= new \Illuminate\Support\Collection(); |
476 | 476 | |
477 | - if($netScores->count() > 0){ |
|
477 | + if($netScores->count() > 0) { |
|
478 | 478 | $netScore = $netScores->first(); |
479 | 479 | |
480 | 480 | $totalNetScore = $netScores->sum('netScore'); |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | $netScores = $this->netScoresByPlayerTopYear($playerId, $top, $year); |
491 | 491 | $cumulativeNet= new \Illuminate\Support\Collection(); |
492 | 492 | |
493 | - if($netScores->count() > 0){ |
|
493 | + if($netScores->count() > 0) { |
|
494 | 494 | $netScore = $netScores->first(); |
495 | 495 | |
496 | 496 | $totalNetScore = $netScores->sum('netScore'); |
@@ -50,7 +50,7 @@ |
||
50 | 50 | */ |
51 | 51 | public function show($id) |
52 | 52 | { |
53 | - $data['data'] =$this->tournamentLeaderboard->get($id); |
|
53 | + $data['data'] = $this->tournamentLeaderboard->get($id); |
|
54 | 54 | return $data; |
55 | 55 | } |
56 | 56 |
@@ -45,7 +45,6 @@ |
||
45 | 45 | /** |
46 | 46 | * Display the specified resource. |
47 | 47 | * |
48 | - * @param int $id |
|
49 | 48 | * @return Response |
50 | 49 | */ |
51 | 50 | public function show($matchId) |
@@ -21,7 +21,7 @@ |
||
21 | 21 | /** |
22 | 22 | * Create a new instance of the MatchHandler |
23 | 23 | * |
24 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
24 | + * @param RoundRepository $roundRepo |
|
25 | 25 | * @return void |
26 | 26 | */ |
27 | 27 | public function __construct(RoundRepository $roundRepo) |
@@ -14,53 +14,53 @@ |
||
14 | 14 | */ |
15 | 15 | class MatchHandler |
16 | 16 | { |
17 | - /** |
|
18 | - * Create a new instance of the MatchHandler |
|
19 | - * |
|
20 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function __construct(RoundRepository $roundRepo) |
|
24 | - { |
|
25 | - $this->roundRepo= $roundRepo; |
|
26 | - } // End of __construct |
|
17 | + /** |
|
18 | + * Create a new instance of the MatchHandler |
|
19 | + * |
|
20 | + * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function __construct(RoundRepository $roundRepo) |
|
24 | + { |
|
25 | + $this->roundRepo= $roundRepo; |
|
26 | + } // End of __construct |
|
27 | 27 | |
28 | - /** |
|
29 | - * Create an initial round for each player after a new match is created |
|
30 | - * |
|
31 | - * @param Match $match |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function handle($match) |
|
35 | - { |
|
36 | - //for each player create an initial round |
|
37 | - $input = array( |
|
38 | - 'date' => $match['date'], |
|
39 | - 'course_id' => $match['course'], |
|
28 | + /** |
|
29 | + * Create an initial round for each player after a new match is created |
|
30 | + * |
|
31 | + * @param Match $match |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function handle($match) |
|
35 | + { |
|
36 | + //for each player create an initial round |
|
37 | + $input = array( |
|
38 | + 'date' => $match['date'], |
|
39 | + 'course_id' => $match['course'], |
|
40 | 40 | |
41 | - 'match_id' => $match['match_id'], |
|
42 | - 'score' => 0, |
|
43 | - 'esc' => 0 |
|
44 | - ); |
|
45 | - foreach($match['player'] as $player){ |
|
46 | - $input['player_id'] = $player['player_id']; |
|
47 | - //If team match then add team id to $input array |
|
48 | - if(isset($player['team'])){ |
|
49 | - $input['team_id'] = $player['team']; |
|
50 | - } |
|
51 | - $this->roundRepo->create($input); |
|
52 | - } |
|
41 | + 'match_id' => $match['match_id'], |
|
42 | + 'score' => 0, |
|
43 | + 'esc' => 0 |
|
44 | + ); |
|
45 | + foreach($match['player'] as $player){ |
|
46 | + $input['player_id'] = $player['player_id']; |
|
47 | + //If team match then add team id to $input array |
|
48 | + if(isset($player['team'])){ |
|
49 | + $input['team_id'] = $player['team']; |
|
50 | + } |
|
51 | + $this->roundRepo->create($input); |
|
52 | + } |
|
53 | 53 | |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Register the listeners for the subscriber. |
|
58 | - * |
|
59 | - * @param Illuminate\Events\Dispatcher $events |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - public function subscribe($events) |
|
63 | - { |
|
64 | - $events->listen('match.create', 'GolfLeague\Handlers\MatchHandler'); |
|
65 | - } |
|
56 | + /** |
|
57 | + * Register the listeners for the subscriber. |
|
58 | + * |
|
59 | + * @param Illuminate\Events\Dispatcher $events |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + public function subscribe($events) |
|
63 | + { |
|
64 | + $events->listen('match.create', 'GolfLeague\Handlers\MatchHandler'); |
|
65 | + } |
|
66 | 66 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct(RoundRepository $roundRepo) |
24 | 24 | { |
25 | - $this->roundRepo= $roundRepo; |
|
25 | + $this->roundRepo = $roundRepo; |
|
26 | 26 | } // End of __construct |
27 | 27 | |
28 | 28 | /** |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | 'score' => 0, |
43 | 43 | 'esc' => 0 |
44 | 44 | ); |
45 | - foreach($match['player'] as $player){ |
|
45 | + foreach ($match['player'] as $player) { |
|
46 | 46 | $input['player_id'] = $player['player_id']; |
47 | 47 | //If team match then add team id to $input array |
48 | - if(isset($player['team'])){ |
|
48 | + if (isset($player['team'])) { |
|
49 | 49 | $input['team_id'] = $player['team']; |
50 | 50 | } |
51 | 51 | $this->roundRepo->create($input); |
@@ -12,8 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | * @author Michael Schmidt |
14 | 14 | */ |
15 | -class MatchHandler |
|
16 | -{ |
|
15 | +class MatchHandler { |
|
17 | 16 | /** |
18 | 17 | * Create a new instance of the MatchHandler |
19 | 18 | * |
@@ -42,10 +41,10 @@ discard block |
||
42 | 41 | 'score' => 0, |
43 | 42 | 'esc' => 0 |
44 | 43 | ); |
45 | - foreach($match['player'] as $player){ |
|
44 | + foreach($match['player'] as $player) { |
|
46 | 45 | $input['player_id'] = $player['player_id']; |
47 | 46 | //If team match then add team id to $input array |
48 | - if(isset($player['team'])){ |
|
47 | + if(isset($player['team'])) { |
|
49 | 48 | $input['team_id'] = $player['team']; |
50 | 49 | } |
51 | 50 | $this->roundRepo->create($input); |