Completed
Push — master ( d565f6...12549b )
by Michael
02:45
created
app/library/Storage/EloquentRepositories/EloquentRoundRepository.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,50 +13,50 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
app/library/Classes/Tournament/TournamentLeaderboardService.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
app/library/Classes/Tournament/TournamentService.php 3 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,31 +9,31 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,15 +6,14 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
app/library/Classes/Tournament/Net.php 3 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,71 +14,71 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
Braces   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
app/library/Classes/Tournament/TournamentFactory.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
app/library/Classes/Statistics/LeagueStatisticsEloquent.php 3 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -11,58 +11,58 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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')
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
Braces   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
app/controllers/TournamentLeaderboardController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
app/controllers/TestController.php 1 patch
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,6 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
app/library/Handlers/MatchHandler.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -14,53 +14,53 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.