Completed
Push — master ( c5f67f...8d1146 )
by Michael
03:07
created
app/library/Classes/Statistics/PlayerStatistics.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -3,38 +3,38 @@
 block discarded – undo
3 3
 
4 4
 interface PlayerStatistics {
5 5
 
6
-    public function matchesHandicap($playerId);
7
-    public function scoringAverage($playerId);
8
-    public function scoringAverageByYear($playerId, $year);
9
-    public function scoringAverageMatchesByYear($year);
10
-    public function handicapRounds($playerId);
11
-
12
-    public function scoringAverageCourse($course);
13
-    public function scoringAverageCourseByYear($course, $year);
14
-    public function scoringAverageCourseMatchesByYear($course, $year);
15
-
16
-    public function totalEagles();
17
-    public function eaglesByYear($year);
18
-    public function eaglesMatchesByYear($year);
19
-
20
-    public function totalBirdies($playerId);
21
-    public function birdiesByYear($playerId, $year);
22
-    public function birdiesMatchesByYear($year);
23
-
24
-    public function totalPars();
25
-    public function parsByYear($year);
26
-    public function parsMatchesByYear($year);
27
-
28
-    public function totalbogeys();
29
-    public function bogeysByYear($year);
30
-    public function bogeysMatchesByYear($year);
31
-
32
-    public function totalDoubles();
33
-    public function doublesByYear($year);
34
-    public function doublesMatchesByYear($year);
35
-
36
-    public function totalOthers();
37
-    public function othersByYear($year);
38
-    public function othersMatchesByYear($year);
6
+	public function matchesHandicap($playerId);
7
+	public function scoringAverage($playerId);
8
+	public function scoringAverageByYear($playerId, $year);
9
+	public function scoringAverageMatchesByYear($year);
10
+	public function handicapRounds($playerId);
11
+
12
+	public function scoringAverageCourse($course);
13
+	public function scoringAverageCourseByYear($course, $year);
14
+	public function scoringAverageCourseMatchesByYear($course, $year);
15
+
16
+	public function totalEagles();
17
+	public function eaglesByYear($year);
18
+	public function eaglesMatchesByYear($year);
19
+
20
+	public function totalBirdies($playerId);
21
+	public function birdiesByYear($playerId, $year);
22
+	public function birdiesMatchesByYear($year);
23
+
24
+	public function totalPars();
25
+	public function parsByYear($year);
26
+	public function parsMatchesByYear($year);
27
+
28
+	public function totalbogeys();
29
+	public function bogeysByYear($year);
30
+	public function bogeysMatchesByYear($year);
31
+
32
+	public function totalDoubles();
33
+	public function doublesByYear($year);
34
+	public function doublesMatchesByYear($year);
35
+
36
+	public function totalOthers();
37
+	public function othersByYear($year);
38
+	public function othersMatchesByYear($year);
39 39
 
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
app/library/Classes/Statistics/PlayerStatisticsEloquent.php 3 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -9,86 +9,86 @@
 block discarded – undo
9 9
 
10 10
 class PlayerStatisticsEloquent implements PlayerStatistics
11 11
 {
12
-    private $date1 = '-01-01';
13
-    private $date2 = '-12-31';
14
-
15
-    public function matchesHandicap($playerId){}
16
-    public function scoringAverage($playerId)
17
-    {
18
-        $rounds = Round::where('match_id', '>', '0')
19
-            ->where('player_id', '=', $playerId)
20
-            ->get();
21
-
22
-        $scores = $rounds->map(function($round)
23
-        {
24
-            return $round->score;
25
-        });
26
-        return round(array_sum($scores->toArray())/($rounds->count()), 2);
27
-    }
28
-    public function scoringAverageByYear($playerId, $year)
29
-    {
30
-        $rounds = Round::where('match_id', '>', '0')
31
-            ->where('player_id', '=', $playerId)
32
-            ->where('date', '>=', $year . $this->date1)
33
-            ->where('date', '<=', $year . $this->date2)
34
-            ->get();
35
-        $scores = $rounds->map(function($round)
36
-        {
37
-            return $round->score;
38
-        });
39
-        if($rounds->count() > 0) {
40
-            return round(array_sum($scores->toArray())/($rounds->count()), 2);
41
-        } else {
42
-            return $rounds;
43
-        }
44
-
45
-
46
-    }
47
-    public function scoringAverageMatchesByYear($year){}
48
-    public function handicapRounds($playerId){}
49
-
50
-    public function scoringAverageCourse($course){}
51
-    public function scoringAverageCourseByYear($course, $year){}
52
-    public function scoringAverageCourseMatchesByYear($course, $year){}
53
-
54
-    public function totalEagles(){}
55
-    public function eaglesByYear($year){}
56
-    public function eaglesMatchesByYear($year){}
57
-
58
-    public function totalBirdies($playerId){}
59
-    public function birdiesByYear($playerId, $year)
60
-    {
61
-        $year = $year . '-01-01';
62
-        $holescores = Holescore::with('round.player','hole')
63
-            ->where('created_at', '>', $year)
64
-            ->get();
65
-        $allBirdies = array();
66
-        foreach($holescores as $key => $holescore) {
67
-            if($holescore['round']['match_id'] != null){
68
-                if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
69
-                    $allBirdies[]= $holescore['round']['player']['id'];
70
-                }
71
-            }
72
-        }
73
-        return count(array_keys($allBirdies, $playerId));
74
-
75
-    }
76
-    public function birdiesMatchesByYear($year){}
77
-
78
-    public function totalPars(){}
79
-    public function parsByYear($year){}
80
-    public function parsMatchesByYear($year){}
81
-
82
-    public function totalbogeys(){}
83
-    public function bogeysByYear($year){}
84
-    public function bogeysMatchesByYear($year){}
85
-
86
-    public function totalDoubles(){}
87
-    public function doublesByYear($year){}
88
-    public function doublesMatchesByYear($year){}
89
-
90
-    public function totalOthers(){}
91
-    public function othersByYear($year){}
92
-    public function othersMatchesByYear($year){}
12
+	private $date1 = '-01-01';
13
+	private $date2 = '-12-31';
14
+
15
+	public function matchesHandicap($playerId){}
16
+	public function scoringAverage($playerId)
17
+	{
18
+		$rounds = Round::where('match_id', '>', '0')
19
+			->where('player_id', '=', $playerId)
20
+			->get();
21
+
22
+		$scores = $rounds->map(function($round)
23
+		{
24
+			return $round->score;
25
+		});
26
+		return round(array_sum($scores->toArray())/($rounds->count()), 2);
27
+	}
28
+	public function scoringAverageByYear($playerId, $year)
29
+	{
30
+		$rounds = Round::where('match_id', '>', '0')
31
+			->where('player_id', '=', $playerId)
32
+			->where('date', '>=', $year . $this->date1)
33
+			->where('date', '<=', $year . $this->date2)
34
+			->get();
35
+		$scores = $rounds->map(function($round)
36
+		{
37
+			return $round->score;
38
+		});
39
+		if($rounds->count() > 0) {
40
+			return round(array_sum($scores->toArray())/($rounds->count()), 2);
41
+		} else {
42
+			return $rounds;
43
+		}
44
+
45
+
46
+	}
47
+	public function scoringAverageMatchesByYear($year){}
48
+	public function handicapRounds($playerId){}
49
+
50
+	public function scoringAverageCourse($course){}
51
+	public function scoringAverageCourseByYear($course, $year){}
52
+	public function scoringAverageCourseMatchesByYear($course, $year){}
53
+
54
+	public function totalEagles(){}
55
+	public function eaglesByYear($year){}
56
+	public function eaglesMatchesByYear($year){}
57
+
58
+	public function totalBirdies($playerId){}
59
+	public function birdiesByYear($playerId, $year)
60
+	{
61
+		$year = $year . '-01-01';
62
+		$holescores = Holescore::with('round.player','hole')
63
+			->where('created_at', '>', $year)
64
+			->get();
65
+		$allBirdies = array();
66
+		foreach($holescores as $key => $holescore) {
67
+			if($holescore['round']['match_id'] != null){
68
+				if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
69
+					$allBirdies[]= $holescore['round']['player']['id'];
70
+				}
71
+			}
72
+		}
73
+		return count(array_keys($allBirdies, $playerId));
74
+
75
+	}
76
+	public function birdiesMatchesByYear($year){}
77
+
78
+	public function totalPars(){}
79
+	public function parsByYear($year){}
80
+	public function parsMatchesByYear($year){}
81
+
82
+	public function totalbogeys(){}
83
+	public function bogeysByYear($year){}
84
+	public function bogeysMatchesByYear($year){}
85
+
86
+	public function totalDoubles(){}
87
+	public function doublesByYear($year){}
88
+	public function doublesMatchesByYear($year){}
89
+
90
+	public function totalOthers(){}
91
+	public function othersByYear($year){}
92
+	public function othersMatchesByYear($year){}
93 93
 
94 94
 }
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     private $date1 = '-01-01';
13 13
     private $date2 = '-12-31';
14 14
 
15
-    public function matchesHandicap($playerId){}
15
+    public function matchesHandicap($playerId) {}
16 16
     public function scoringAverage($playerId)
17 17
     {
18 18
         $rounds = Round::where('match_id', '>', '0')
@@ -23,72 +23,72 @@  discard block
 block discarded – undo
23 23
         {
24 24
             return $round->score;
25 25
         });
26
-        return round(array_sum($scores->toArray())/($rounds->count()), 2);
26
+        return round(array_sum($scores->toArray()) / ($rounds->count()), 2);
27 27
     }
28 28
     public function scoringAverageByYear($playerId, $year)
29 29
     {
30 30
         $rounds = Round::where('match_id', '>', '0')
31 31
             ->where('player_id', '=', $playerId)
32
-            ->where('date', '>=', $year . $this->date1)
33
-            ->where('date', '<=', $year . $this->date2)
32
+            ->where('date', '>=', $year.$this->date1)
33
+            ->where('date', '<=', $year.$this->date2)
34 34
             ->get();
35 35
         $scores = $rounds->map(function($round)
36 36
         {
37 37
             return $round->score;
38 38
         });
39
-        if($rounds->count() > 0) {
40
-            return round(array_sum($scores->toArray())/($rounds->count()), 2);
39
+        if ($rounds->count() > 0) {
40
+            return round(array_sum($scores->toArray()) / ($rounds->count()), 2);
41 41
         } else {
42 42
             return $rounds;
43 43
         }
44 44
 
45 45
 
46 46
     }
47
-    public function scoringAverageMatchesByYear($year){}
48
-    public function handicapRounds($playerId){}
47
+    public function scoringAverageMatchesByYear($year) {}
48
+    public function handicapRounds($playerId) {}
49 49
 
50
-    public function scoringAverageCourse($course){}
51
-    public function scoringAverageCourseByYear($course, $year){}
52
-    public function scoringAverageCourseMatchesByYear($course, $year){}
50
+    public function scoringAverageCourse($course) {}
51
+    public function scoringAverageCourseByYear($course, $year) {}
52
+    public function scoringAverageCourseMatchesByYear($course, $year) {}
53 53
 
54
-    public function totalEagles(){}
55
-    public function eaglesByYear($year){}
56
-    public function eaglesMatchesByYear($year){}
54
+    public function totalEagles() {}
55
+    public function eaglesByYear($year) {}
56
+    public function eaglesMatchesByYear($year) {}
57 57
 
58
-    public function totalBirdies($playerId){}
58
+    public function totalBirdies($playerId) {}
59 59
     public function birdiesByYear($playerId, $year)
60 60
     {
61
-        $year = $year . '-01-01';
62
-        $holescores = Holescore::with('round.player','hole')
61
+        $year = $year.'-01-01';
62
+        $holescores = Holescore::with('round.player', 'hole')
63 63
             ->where('created_at', '>', $year)
64 64
             ->get();
65 65
         $allBirdies = array();
66
-        foreach($holescores as $key => $holescore) {
67
-            if($holescore['round']['match_id'] != null){
68
-                if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
69
-                    $allBirdies[]= $holescore['round']['player']['id'];
66
+        foreach ($holescores as $key => $holescore) {
67
+            if ($holescore['round']['match_id'] != null) {
68
+                if (($holescore['hole']['par'] - $holescore['score']) === 1) {
69
+                    $allBirdies[] = $holescore['round']['player']['id'];
70 70
                 }
71 71
             }
72 72
         }
73 73
         return count(array_keys($allBirdies, $playerId));
74 74
 
75 75
     }
76
-    public function birdiesMatchesByYear($year){}
76
+    public function birdiesMatchesByYear($year) {}
77 77
 
78
-    public function totalPars(){}
79
-    public function parsByYear($year){}
80
-    public function parsMatchesByYear($year){}
78
+    public function totalPars() {}
79
+    public function parsByYear($year) {}
80
+    public function parsMatchesByYear($year) {}
81 81
 
82
-    public function totalbogeys(){}
83
-    public function bogeysByYear($year){}
84
-    public function bogeysMatchesByYear($year){}
82
+    public function totalbogeys() {}
83
+    public function bogeysByYear($year) {}
84
+    public function bogeysMatchesByYear($year) {}
85 85
 
86
-    public function totalDoubles(){}
87
-    public function doublesByYear($year){}
88
-    public function doublesMatchesByYear($year){}
86
+    public function totalDoubles() {}
87
+    public function doublesByYear($year) {}
88
+    public function doublesMatchesByYear($year) {}
89 89
 
90
-    public function totalOthers(){}
91
-    public function othersByYear($year){}
92
-    public function othersMatchesByYear($year){}
90
+    public function totalOthers() {}
91
+    public function othersByYear($year) {}
92
+    public function othersMatchesByYear($year) {}
93 93
 
94 94
 }
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +71 added lines, -26 removed lines patch added patch discarded remove patch
@@ -7,12 +7,13 @@  discard block
 block discarded – undo
7 7
 use \Holescore;
8 8
 
9 9
 
10
-class PlayerStatisticsEloquent implements PlayerStatistics
11
-{
10
+class PlayerStatisticsEloquent implements PlayerStatistics {
12 11
     private $date1 = '-01-01';
13 12
     private $date2 = '-12-31';
14 13
 
15
-    public function matchesHandicap($playerId){}
14
+    public function matchesHandicap($playerId)
15
+    {
16
+}
16 17
     public function scoringAverage($playerId)
17 18
     {
18 19
         $rounds = Round::where('match_id', '>', '0')
@@ -44,18 +45,36 @@  discard block
 block discarded – undo
44 45
 
45 46
 
46 47
     }
47
-    public function scoringAverageMatchesByYear($year){}
48
-    public function handicapRounds($playerId){}
48
+    public function scoringAverageMatchesByYear($year)
49
+    {
50
+}
51
+    public function handicapRounds($playerId)
52
+    {
53
+}
49 54
 
50
-    public function scoringAverageCourse($course){}
51
-    public function scoringAverageCourseByYear($course, $year){}
52
-    public function scoringAverageCourseMatchesByYear($course, $year){}
55
+    public function scoringAverageCourse($course)
56
+    {
57
+}
58
+    public function scoringAverageCourseByYear($course, $year)
59
+    {
60
+}
61
+    public function scoringAverageCourseMatchesByYear($course, $year)
62
+    {
63
+}
53 64
 
54
-    public function totalEagles(){}
55
-    public function eaglesByYear($year){}
56
-    public function eaglesMatchesByYear($year){}
65
+    public function totalEagles()
66
+    {
67
+}
68
+    public function eaglesByYear($year)
69
+    {
70
+}
71
+    public function eaglesMatchesByYear($year)
72
+    {
73
+}
57 74
 
58
-    public function totalBirdies($playerId){}
75
+    public function totalBirdies($playerId)
76
+    {
77
+}
59 78
     public function birdiesByYear($playerId, $year)
60 79
     {
61 80
         $year = $year . '-01-01';
@@ -64,7 +83,7 @@  discard block
 block discarded – undo
64 83
             ->get();
65 84
         $allBirdies = array();
66 85
         foreach($holescores as $key => $holescore) {
67
-            if($holescore['round']['match_id'] != null){
86
+            if($holescore['round']['match_id'] != null) {
68 87
                 if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
69 88
                     $allBirdies[]= $holescore['round']['player']['id'];
70 89
                 }
@@ -73,22 +92,48 @@  discard block
 block discarded – undo
73 92
         return count(array_keys($allBirdies, $playerId));
74 93
 
75 94
     }
76
-    public function birdiesMatchesByYear($year){}
95
+    public function birdiesMatchesByYear($year)
96
+    {
97
+}
77 98
 
78
-    public function totalPars(){}
79
-    public function parsByYear($year){}
80
-    public function parsMatchesByYear($year){}
99
+    public function totalPars()
100
+    {
101
+}
102
+    public function parsByYear($year)
103
+    {
104
+}
105
+    public function parsMatchesByYear($year)
106
+    {
107
+}
81 108
 
82
-    public function totalbogeys(){}
83
-    public function bogeysByYear($year){}
84
-    public function bogeysMatchesByYear($year){}
109
+    public function totalbogeys()
110
+    {
111
+}
112
+    public function bogeysByYear($year)
113
+    {
114
+}
115
+    public function bogeysMatchesByYear($year)
116
+    {
117
+}
85 118
 
86
-    public function totalDoubles(){}
87
-    public function doublesByYear($year){}
88
-    public function doublesMatchesByYear($year){}
119
+    public function totalDoubles()
120
+    {
121
+}
122
+    public function doublesByYear($year)
123
+    {
124
+}
125
+    public function doublesMatchesByYear($year)
126
+    {
127
+}
89 128
 
90
-    public function totalOthers(){}
91
-    public function othersByYear($year){}
92
-    public function othersMatchesByYear($year){}
129
+    public function totalOthers()
130
+    {
131
+}
132
+    public function othersByYear($year)
133
+    {
134
+}
135
+    public function othersMatchesByYear($year)
136
+    {
137
+}
93 138
 
94 139
 }
95 140
\ No newline at end of file
Please login to merge, or discard this patch.
app/library/Classes/Statistics/LeagueStatisticsEloquent.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -8,55 +8,55 @@  discard block
 block discarded – undo
8 8
 
9 9
 class LeagueStatisticsEloquent implements LeagueStatistics
10 10
 {
11
-    public function topFiveLowestScores()
12
-    {
13
-        return Round::with('player','course')->orderBy('score')->take(5)->get();
14
-    }
15
-    public function topFiveLowestScoresByYear($year)
16
-    {
17
-        $date1 = $year . '-01-01';
18
-        $date2 = $year . '-12-31';
19
-        return Round::with('player', 'course')
20
-            ->where('match_id', '>', '0')
21
-            ->where('date', '>=', $date1)
22
-            ->where('date', '<=', $date2)
23
-            ->orderBy('score')
24
-            ->take(5)
25
-            ->get();
26
-    }
27
-    public function topFiveScoringAverageByYear($year)
28
-    {
29
-        //Get players
30
-        //For each player where match > 0 select scores and average them
31
-        //Store in players array
32
-        $date1 = $year . '-01-01';
33
-        $date2 = $year . '-12-31';
34
-        $players = Player::all();
35
-        $average = array();
36
-        $i = 0;
37
-        foreach($players as $key => $player) {
38
-            $rounds = Round::where('match_id', '>', '0')
39
-                ->where('player_id', '=', $player->id)
40
-                ->where('date', '>=', $date1)
41
-                ->where('date', '<=', $date2)
42
-                ->get();
43
-            $scores = array();
11
+	public function topFiveLowestScores()
12
+	{
13
+		return Round::with('player','course')->orderBy('score')->take(5)->get();
14
+	}
15
+	public function topFiveLowestScoresByYear($year)
16
+	{
17
+		$date1 = $year . '-01-01';
18
+		$date2 = $year . '-12-31';
19
+		return Round::with('player', 'course')
20
+			->where('match_id', '>', '0')
21
+			->where('date', '>=', $date1)
22
+			->where('date', '<=', $date2)
23
+			->orderBy('score')
24
+			->take(5)
25
+			->get();
26
+	}
27
+	public function topFiveScoringAverageByYear($year)
28
+	{
29
+		//Get players
30
+		//For each player where match > 0 select scores and average them
31
+		//Store in players array
32
+		$date1 = $year . '-01-01';
33
+		$date2 = $year . '-12-31';
34
+		$players = Player::all();
35
+		$average = array();
36
+		$i = 0;
37
+		foreach($players as $key => $player) {
38
+			$rounds = Round::where('match_id', '>', '0')
39
+				->where('player_id', '=', $player->id)
40
+				->where('date', '>=', $date1)
41
+				->where('date', '<=', $date2)
42
+				->get();
43
+			$scores = array();
44 44
 			foreach($rounds as $round) {
45 45
 				$scores[] = $round->score;
46 46
 			}
47
-            if(count($scores) > 0) {
48
-                $average[$i]['average'] = round((array_sum($scores) / count($scores)) ,2);
49
-                $average[$i]['player_id'] = $player->id;
50
-                $average[$i]['name'] = $player->name;
51
-                $average[$i]['rounds'] = count($scores);
52
-                $i++;
53
-            }
54
-        }
55
-        array_multisort($average);
56
-        return $average;
57
-    }
58
-    public function topFiveNetScoresByYear($year)
59
-    {
47
+			if(count($scores) > 0) {
48
+				$average[$i]['average'] = round((array_sum($scores) / count($scores)) ,2);
49
+				$average[$i]['player_id'] = $player->id;
50
+				$average[$i]['name'] = $player->name;
51
+				$average[$i]['rounds'] = count($scores);
52
+				$i++;
53
+			}
54
+		}
55
+		array_multisort($average);
56
+		return $average;
57
+	}
58
+	public function topFiveNetScoresByYear($year)
59
+	{
60 60
 		$date1 = $year . '-01-01';
61 61
 		$date2 = $year . '-12-31';
62 62
 
@@ -64,29 +64,29 @@  discard block
 block discarded – undo
64 64
 				->where('created_at', '>=', $date1)
65 65
 				->where('created_at', '<=', $date2)
66 66
 				->orderBy('score')->take(5)->get();
67
-    }
68
-    public function mostSkinsByYear($year)
69
-    {
70
-        $year = $year . '-01-01';
71
-        $players = Player::all();
72
-        $i = 0;
73
-        $skinsCount = array();
74
-        foreach($players as $key => $player) {
75
-            $skins = Skin::with('player','level')
76
-                ->where('player_id', '=', $player->id)
77
-                ->where('created_at', '>', $year)
78
-                ->get();
79
-            if(count($skins) > 0) {
80
-                $skinsCount[$i]['skins'] = $skins->count();
81
-                $skinsCount[$i]['name'] = $player->name;
82
-                $i++;
83
-            }
84
-        }
85
-        array_multisort($skinsCount, SORT_DESC);
86
-        return $skinsCount;
87
-    }
88
-    public function totalEagles($year){}
89
-    public function totalBirdies($year)
67
+	}
68
+	public function mostSkinsByYear($year)
69
+	{
70
+		$year = $year . '-01-01';
71
+		$players = Player::all();
72
+		$i = 0;
73
+		$skinsCount = array();
74
+		foreach($players as $key => $player) {
75
+			$skins = Skin::with('player','level')
76
+				->where('player_id', '=', $player->id)
77
+				->where('created_at', '>', $year)
78
+				->get();
79
+			if(count($skins) > 0) {
80
+				$skinsCount[$i]['skins'] = $skins->count();
81
+				$skinsCount[$i]['name'] = $player->name;
82
+				$i++;
83
+			}
84
+		}
85
+		array_multisort($skinsCount, SORT_DESC);
86
+		return $skinsCount;
87
+	}
88
+	public function totalEagles($year){}
89
+	public function totalBirdies($year)
90 90
 	{
91 91
 		$year = $year . '-01-01';
92 92
 		$holescores = Holescore::with('round.player','hole')
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 			}
111 111
 			return $birds;
112 112
 	}
113
-    public function totalPars($year)
113
+	public function totalPars($year)
114 114
 	{
115 115
 		$year = $year . '-01-01';
116 116
 		$holescores = Holescore::with('round.player','hole')
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 			}
135 135
 			return $pars;
136 136
 	}
137
-    public function totalBogeys($year)
137
+	public function totalBogeys($year)
138 138
 	{
139 139
 		$year = $year . '-01-01';
140 140
 		$holescores = Holescore::with('round.player','hole')
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			}
159 159
 		return $bogeys;
160 160
 	}
161
-    public function totalDoubles($year)
161
+	public function totalDoubles($year)
162 162
 	{
163 163
 		$year = $year . '-01-01';
164 164
 		$holescores = Holescore::with('round.player','hole')
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			}
183 183
 		return $doubles;
184 184
 	}
185
-    public function totalOthers($year)
185
+	public function totalOthers($year)
186 186
 	{
187 187
 		$year = $year . '-01-01';
188 188
 		$holescores = Holescore::with('round.player','hole')
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
 {
11 11
     public function topFiveLowestScores()
12 12
     {
13
-        return Round::with('player','course')->orderBy('score')->take(5)->get();
13
+        return Round::with('player', 'course')->orderBy('score')->take(5)->get();
14 14
     }
15 15
     public function topFiveLowestScoresByYear($year)
16 16
     {
17
-        $date1 = $year . '-01-01';
18
-        $date2 = $year . '-12-31';
17
+        $date1 = $year.'-01-01';
18
+        $date2 = $year.'-12-31';
19 19
         return Round::with('player', 'course')
20 20
             ->where('match_id', '>', '0')
21 21
             ->where('date', '>=', $date1)
@@ -29,23 +29,23 @@  discard block
 block discarded – undo
29 29
         //Get players
30 30
         //For each player where match > 0 select scores and average them
31 31
         //Store in players array
32
-        $date1 = $year . '-01-01';
33
-        $date2 = $year . '-12-31';
32
+        $date1 = $year.'-01-01';
33
+        $date2 = $year.'-12-31';
34 34
         $players = Player::all();
35 35
         $average = array();
36 36
         $i = 0;
37
-        foreach($players as $key => $player) {
37
+        foreach ($players as $key => $player) {
38 38
             $rounds = Round::where('match_id', '>', '0')
39 39
                 ->where('player_id', '=', $player->id)
40 40
                 ->where('date', '>=', $date1)
41 41
                 ->where('date', '<=', $date2)
42 42
                 ->get();
43 43
             $scores = array();
44
-			foreach($rounds as $round) {
44
+			foreach ($rounds as $round) {
45 45
 				$scores[] = $round->score;
46 46
 			}
47
-            if(count($scores) > 0) {
48
-                $average[$i]['average'] = round((array_sum($scores) / count($scores)) ,2);
47
+            if (count($scores) > 0) {
48
+                $average[$i]['average'] = round((array_sum($scores) / count($scores)), 2);
49 49
                 $average[$i]['player_id'] = $player->id;
50 50
                 $average[$i]['name'] = $player->name;
51 51
                 $average[$i]['rounds'] = count($scores);
@@ -57,26 +57,26 @@  discard block
 block discarded – undo
57 57
     }
58 58
     public function topFiveNetScoresByYear($year)
59 59
     {
60
-		$date1 = $year . '-01-01';
61
-		$date2 = $year . '-12-31';
60
+		$date1 = $year.'-01-01';
61
+		$date2 = $year.'-12-31';
62 62
 
63
-		return Netwinner::with('player','match','match.course')
63
+		return Netwinner::with('player', 'match', 'match.course')
64 64
 				->where('created_at', '>=', $date1)
65 65
 				->where('created_at', '<=', $date2)
66 66
 				->orderBy('score')->take(5)->get();
67 67
     }
68 68
     public function mostSkinsByYear($year)
69 69
     {
70
-        $year = $year . '-01-01';
70
+        $year = $year.'-01-01';
71 71
         $players = Player::all();
72 72
         $i = 0;
73 73
         $skinsCount = array();
74
-        foreach($players as $key => $player) {
75
-            $skins = Skin::with('player','level')
74
+        foreach ($players as $key => $player) {
75
+            $skins = Skin::with('player', 'level')
76 76
                 ->where('player_id', '=', $player->id)
77 77
                 ->where('created_at', '>', $year)
78 78
                 ->get();
79
-            if(count($skins) > 0) {
79
+            if (count($skins) > 0) {
80 80
                 $skinsCount[$i]['skins'] = $skins->count();
81 81
                 $skinsCount[$i]['name'] = $player->name;
82 82
                 $i++;
@@ -85,66 +85,66 @@  discard block
 block discarded – undo
85 85
         array_multisort($skinsCount, SORT_DESC);
86 86
         return $skinsCount;
87 87
     }
88
-    public function totalEagles($year){}
88
+    public function totalEagles($year) {}
89 89
     public function totalBirdies($year)
90 90
 	{
91
-		$year = $year . '-01-01';
92
-		$holescores = Holescore::with('round.player','hole')
91
+		$year = $year.'-01-01';
92
+		$holescores = Holescore::with('round.player', 'hole')
93 93
 			->where('created_at', '>', $year)
94 94
 			->get();
95 95
 		$allBirdies = array();
96
-		foreach($holescores as $key => $holescore) {
97
-			if($holescore['round']['match_id'] != null){
98
-				if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
99
-						$allBirdies[]= $holescore['round']['player']['name'];
96
+		foreach ($holescores as $key => $holescore) {
97
+			if ($holescore['round']['match_id'] != null) {
98
+				if (($holescore['hole']['par'] - $holescore['score']) === 1) {
99
+						$allBirdies[] = $holescore['round']['player']['name'];
100 100
 				}
101 101
 			}
102 102
 		}
103
-		$i =0;
103
+		$i = 0;
104 104
 		$newArray = array_count_values($allBirdies);
105 105
 			$birds = array();
106 106
 			foreach ($newArray as $key => $value) {
107 107
 				$birds[$i]['name'] = $key;
108
-				$birds[$i]['birds'] =$value;
108
+				$birds[$i]['birds'] = $value;
109 109
 				$i++;
110 110
 			}
111 111
 			return $birds;
112 112
 	}
113 113
     public function totalPars($year)
114 114
 	{
115
-		$year = $year . '-01-01';
116
-		$holescores = Holescore::with('round.player','hole')
115
+		$year = $year.'-01-01';
116
+		$holescores = Holescore::with('round.player', 'hole')
117 117
 			->where('created_at', '>', $year)
118 118
 			->get();
119 119
 		$allPars = array();
120
-		foreach($holescores as $key => $holescore) {
121
-			if($holescore['round']['match_id'] != null){
122
-				if( ($holescore['hole']['par'] - $holescore['score']) === 0) {
123
-						$allPars[]= $holescore['round']['player']['name'];
120
+		foreach ($holescores as $key => $holescore) {
121
+			if ($holescore['round']['match_id'] != null) {
122
+				if (($holescore['hole']['par'] - $holescore['score']) === 0) {
123
+						$allPars[] = $holescore['round']['player']['name'];
124 124
 				}
125 125
 			}
126 126
 		}
127
-		$i =0;
127
+		$i = 0;
128 128
 		$newArray = array_count_values($allPars);
129 129
 			$pars = array();
130 130
 			foreach ($newArray as $key => $value) {
131 131
 				$pars[$i]['name'] = $key;
132
-				$pars[$i]['pars'] =$value;
132
+				$pars[$i]['pars'] = $value;
133 133
 				$i++;
134 134
 			}
135 135
 			return $pars;
136 136
 	}
137 137
     public function totalBogeys($year)
138 138
 	{
139
-		$year = $year . '-01-01';
140
-		$holescores = Holescore::with('round.player','hole')
139
+		$year = $year.'-01-01';
140
+		$holescores = Holescore::with('round.player', 'hole')
141 141
 			->where('created_at', '>', $year)
142 142
 			->get();
143 143
 		$allBogeys = array();
144
-		foreach($holescores as $key => $holescore) {
145
-			if($holescore['round']['match_id'] != null){
146
-				if( ($holescore['score'] - $holescore['hole']['par']) === 1) {
147
-						$allBogeys[]= $holescore['round']['player']['name'];
144
+		foreach ($holescores as $key => $holescore) {
145
+			if ($holescore['round']['match_id'] != null) {
146
+				if (($holescore['score'] - $holescore['hole']['par']) === 1) {
147
+						$allBogeys[] = $holescore['round']['player']['name'];
148 148
 				}
149 149
 			}
150 150
 		}
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
 		$bogeys = array();
154 154
 			foreach ($newArray as $key => $value) {
155 155
 				$bogeys[$i]['name'] = $key;
156
-				$bogeys[$i]['bogeys'] =$value;
156
+				$bogeys[$i]['bogeys'] = $value;
157 157
 				$i++;
158 158
 			}
159 159
 		return $bogeys;
160 160
 	}
161 161
     public function totalDoubles($year)
162 162
 	{
163
-		$year = $year . '-01-01';
164
-		$holescores = Holescore::with('round.player','hole')
163
+		$year = $year.'-01-01';
164
+		$holescores = Holescore::with('round.player', 'hole')
165 165
 			->where('created_at', '>', $year)
166 166
 			->get();
167 167
 		$allDoubles = array();
168
-		foreach($holescores as $key => $holescore) {
169
-			if($holescore['round']['match_id'] != null){
170
-				if( ($holescore['score'] - $holescore['hole']['par']) === 2) {
171
-						$allDoubles[]= $holescore['round']['player']['name'];
168
+		foreach ($holescores as $key => $holescore) {
169
+			if ($holescore['round']['match_id'] != null) {
170
+				if (($holescore['score'] - $holescore['hole']['par']) === 2) {
171
+						$allDoubles[] = $holescore['round']['player']['name'];
172 172
 				}
173 173
 			}
174 174
 		}
@@ -177,22 +177,22 @@  discard block
 block discarded – undo
177 177
 			$doubles = array();
178 178
 			foreach ($newArray as $key => $value) {
179 179
 				$doubles[$i]['name'] = $key;
180
-				$doubles[$i]['doubles'] =$value;
180
+				$doubles[$i]['doubles'] = $value;
181 181
 				$i++;
182 182
 			}
183 183
 		return $doubles;
184 184
 	}
185 185
     public function totalOthers($year)
186 186
 	{
187
-		$year = $year . '-01-01';
188
-		$holescores = Holescore::with('round.player','hole')
187
+		$year = $year.'-01-01';
188
+		$holescores = Holescore::with('round.player', 'hole')
189 189
 			->where('created_at', '>', $year)
190 190
 			->get();
191 191
 		$allOthers = array();
192
-		foreach($holescores as $key => $holescore) {
193
-			if($holescore['round']['match_id'] != null){
194
-				if( ($holescore['score'] - $holescore['hole']['par']) > 2) {
195
-					$allOthers[]= $holescore['round']['player']['name'];
192
+		foreach ($holescores as $key => $holescore) {
193
+			if ($holescore['round']['match_id'] != null) {
194
+				if (($holescore['score'] - $holescore['hole']['par']) > 2) {
195
+					$allOthers[] = $holescore['round']['player']['name'];
196 196
 				}
197 197
 			}
198 198
 		}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		$others = array();
202 202
 			foreach ($newArray as $key => $value) {
203 203
 				$others[$i]['name'] = $key;
204
-				$others[$i]['others'] =$value;
204
+				$others[$i]['others'] = $value;
205 205
 				$i++;
206 206
 			}
207 207
 		return $others;
Please login to merge, or discard this patch.