Completed
Push — master ( 5924c0...dedfd9 )
by Michael
05:35
created
app/library/Classes/Statistics/LeagueStatisticsEloquent.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -8,56 +8,56 @@  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();
44
-            foreach($rounds as $round) {
45
-                $scores[] = $round->score;
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
-    }
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
+			foreach($rounds as $round) {
45
+				$scores[] = $round->score;
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 58
 
59
-    public function topFiveNetScoresByYear($year)
60
-    {
59
+	public function topFiveNetScoresByYear($year)
60
+	{
61 61
 		$date1 = $year . '-01-01';
62 62
 		$date2 = $year . '-12-31';
63 63
 
@@ -65,30 +65,30 @@  discard block
 block discarded – undo
65 65
 				->where('created_at', '>=', $date1)
66 66
 				->where('created_at', '<=', $date2)
67 67
 				->orderBy('score')->take(5)->get();
68
-    }
68
+	}
69 69
 
70
-    public function mostSkinsByYear($year)
71
-    {
72
-        $year = $year . '-01-01';
73
-        $players = Player::all();
74
-        $i = 0;
75
-        $skinsCount = array();
76
-        foreach($players as $key => $player) {
77
-            $skins = Skin::with('player','level')
78
-                ->where('player_id', '=', $player->id)
79
-                ->where('created_at', '>', $year)
80
-                ->get();
81
-            if(count($skins) > 0) {
82
-                $skinsCount[$i]['skins'] = $skins->count();
83
-                $skinsCount[$i]['name'] = $player->name;
84
-                $i++;
85
-            }
86
-        }
87
-        array_multisort($skinsCount, SORT_DESC);
88
-        return $skinsCount;
89
-    }
90
-    public function totalEagles($year){}
91
-    public function totalBirdies($year)
70
+	public function mostSkinsByYear($year)
71
+	{
72
+		$year = $year . '-01-01';
73
+		$players = Player::all();
74
+		$i = 0;
75
+		$skinsCount = array();
76
+		foreach($players as $key => $player) {
77
+			$skins = Skin::with('player','level')
78
+				->where('player_id', '=', $player->id)
79
+				->where('created_at', '>', $year)
80
+				->get();
81
+			if(count($skins) > 0) {
82
+				$skinsCount[$i]['skins'] = $skins->count();
83
+				$skinsCount[$i]['name'] = $player->name;
84
+				$i++;
85
+			}
86
+		}
87
+		array_multisort($skinsCount, SORT_DESC);
88
+		return $skinsCount;
89
+	}
90
+	public function totalEagles($year){}
91
+	public function totalBirdies($year)
92 92
 	{
93 93
 		$year = $year . '-01-01';
94 94
 		$holescores = Holescore::with('round.player','hole')
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 			}
113 113
 			return $birds;
114 114
 	}
115
-    public function totalPars($year)
115
+	public function totalPars($year)
116 116
 	{
117 117
 		$year = $year . '-01-01';
118 118
 		$holescores = Holescore::with('round.player','hole')
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			}
137 137
 			return $pars;
138 138
 	}
139
-    public function totalBogeys($year)
139
+	public function totalBogeys($year)
140 140
 	{
141 141
 		$year = $year . '-01-01';
142 142
 		$holescores = Holescore::with('round.player','hole')
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			}
161 161
 		return $bogeys;
162 162
 	}
163
-    public function totalDoubles($year)
163
+	public function totalDoubles($year)
164 164
 	{
165 165
 		$year = $year . '-01-01';
166 166
 		$holescores = Holescore::with('round.player','hole')
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 			}
185 185
 		return $doubles;
186 186
 	}
187
-    public function totalOthers($year)
187
+	public function totalOthers($year)
188 188
 	{
189 189
 		$year = $year . '-01-01';
190 190
 		$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);
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 
59 59
     public function topFiveNetScoresByYear($year)
60 60
     {
61
-		$date1 = $year . '-01-01';
62
-		$date2 = $year . '-12-31';
61
+		$date1 = $year.'-01-01';
62
+		$date2 = $year.'-12-31';
63 63
 
64
-		return Netwinner::with('player','match','match.course')
64
+		return Netwinner::with('player', 'match', 'match.course')
65 65
 				->where('created_at', '>=', $date1)
66 66
 				->where('created_at', '<=', $date2)
67 67
 				->orderBy('score')->take(5)->get();
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
 
70 70
     public function mostSkinsByYear($year)
71 71
     {
72
-        $year = $year . '-01-01';
72
+        $year = $year.'-01-01';
73 73
         $players = Player::all();
74 74
         $i = 0;
75 75
         $skinsCount = array();
76
-        foreach($players as $key => $player) {
77
-            $skins = Skin::with('player','level')
76
+        foreach ($players as $key => $player) {
77
+            $skins = Skin::with('player', 'level')
78 78
                 ->where('player_id', '=', $player->id)
79 79
                 ->where('created_at', '>', $year)
80 80
                 ->get();
81
-            if(count($skins) > 0) {
81
+            if (count($skins) > 0) {
82 82
                 $skinsCount[$i]['skins'] = $skins->count();
83 83
                 $skinsCount[$i]['name'] = $player->name;
84 84
                 $i++;
@@ -87,66 +87,66 @@  discard block
 block discarded – undo
87 87
         array_multisort($skinsCount, SORT_DESC);
88 88
         return $skinsCount;
89 89
     }
90
-    public function totalEagles($year){}
90
+    public function totalEagles($year) {}
91 91
     public function totalBirdies($year)
92 92
 	{
93
-		$year = $year . '-01-01';
94
-		$holescores = Holescore::with('round.player','hole')
93
+		$year = $year.'-01-01';
94
+		$holescores = Holescore::with('round.player', 'hole')
95 95
 			->where('created_at', '>', $year)
96 96
 			->get();
97 97
 		$allBirdies = array();
98
-		foreach($holescores as $key => $holescore) {
99
-			if($holescore['round']['match_id'] != null){
100
-				if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
101
-						$allBirdies[]= $holescore['round']['player']['name'];
98
+		foreach ($holescores as $key => $holescore) {
99
+			if ($holescore['round']['match_id'] != null) {
100
+				if (($holescore['hole']['par'] - $holescore['score']) === 1) {
101
+						$allBirdies[] = $holescore['round']['player']['name'];
102 102
 				}
103 103
 			}
104 104
 		}
105
-		$i =0;
105
+		$i = 0;
106 106
 		$newArray = array_count_values($allBirdies);
107 107
 			$birds = array();
108 108
 			foreach ($newArray as $key => $value) {
109 109
 				$birds[$i]['name'] = $key;
110
-				$birds[$i]['birds'] =$value;
110
+				$birds[$i]['birds'] = $value;
111 111
 				$i++;
112 112
 			}
113 113
 			return $birds;
114 114
 	}
115 115
     public function totalPars($year)
116 116
 	{
117
-		$year = $year . '-01-01';
118
-		$holescores = Holescore::with('round.player','hole')
117
+		$year = $year.'-01-01';
118
+		$holescores = Holescore::with('round.player', 'hole')
119 119
 			->where('created_at', '>', $year)
120 120
 			->get();
121 121
 		$allPars = array();
122
-		foreach($holescores as $key => $holescore) {
123
-			if($holescore['round']['match_id'] != null){
124
-				if( ($holescore['hole']['par'] - $holescore['score']) === 0) {
125
-						$allPars[]= $holescore['round']['player']['name'];
122
+		foreach ($holescores as $key => $holescore) {
123
+			if ($holescore['round']['match_id'] != null) {
124
+				if (($holescore['hole']['par'] - $holescore['score']) === 0) {
125
+						$allPars[] = $holescore['round']['player']['name'];
126 126
 				}
127 127
 			}
128 128
 		}
129
-		$i =0;
129
+		$i = 0;
130 130
 		$newArray = array_count_values($allPars);
131 131
 			$pars = array();
132 132
 			foreach ($newArray as $key => $value) {
133 133
 				$pars[$i]['name'] = $key;
134
-				$pars[$i]['pars'] =$value;
134
+				$pars[$i]['pars'] = $value;
135 135
 				$i++;
136 136
 			}
137 137
 			return $pars;
138 138
 	}
139 139
     public function totalBogeys($year)
140 140
 	{
141
-		$year = $year . '-01-01';
142
-		$holescores = Holescore::with('round.player','hole')
141
+		$year = $year.'-01-01';
142
+		$holescores = Holescore::with('round.player', 'hole')
143 143
 			->where('created_at', '>', $year)
144 144
 			->get();
145 145
 		$allBogeys = array();
146
-		foreach($holescores as $key => $holescore) {
147
-			if($holescore['round']['match_id'] != null){
148
-				if( ($holescore['score'] - $holescore['hole']['par']) === 1) {
149
-						$allBogeys[]= $holescore['round']['player']['name'];
146
+		foreach ($holescores as $key => $holescore) {
147
+			if ($holescore['round']['match_id'] != null) {
148
+				if (($holescore['score'] - $holescore['hole']['par']) === 1) {
149
+						$allBogeys[] = $holescore['round']['player']['name'];
150 150
 				}
151 151
 			}
152 152
 		}
@@ -155,22 +155,22 @@  discard block
 block discarded – undo
155 155
 		$bogeys = array();
156 156
 			foreach ($newArray as $key => $value) {
157 157
 				$bogeys[$i]['name'] = $key;
158
-				$bogeys[$i]['bogeys'] =$value;
158
+				$bogeys[$i]['bogeys'] = $value;
159 159
 				$i++;
160 160
 			}
161 161
 		return $bogeys;
162 162
 	}
163 163
     public function totalDoubles($year)
164 164
 	{
165
-		$year = $year . '-01-01';
166
-		$holescores = Holescore::with('round.player','hole')
165
+		$year = $year.'-01-01';
166
+		$holescores = Holescore::with('round.player', 'hole')
167 167
 			->where('created_at', '>', $year)
168 168
 			->get();
169 169
 		$allDoubles = array();
170
-		foreach($holescores as $key => $holescore) {
171
-			if($holescore['round']['match_id'] != null){
172
-				if( ($holescore['score'] - $holescore['hole']['par']) === 2) {
173
-						$allDoubles[]= $holescore['round']['player']['name'];
170
+		foreach ($holescores as $key => $holescore) {
171
+			if ($holescore['round']['match_id'] != null) {
172
+				if (($holescore['score'] - $holescore['hole']['par']) === 2) {
173
+						$allDoubles[] = $holescore['round']['player']['name'];
174 174
 				}
175 175
 			}
176 176
 		}
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
 			$doubles = array();
180 180
 			foreach ($newArray as $key => $value) {
181 181
 				$doubles[$i]['name'] = $key;
182
-				$doubles[$i]['doubles'] =$value;
182
+				$doubles[$i]['doubles'] = $value;
183 183
 				$i++;
184 184
 			}
185 185
 		return $doubles;
186 186
 	}
187 187
     public function totalOthers($year)
188 188
 	{
189
-		$year = $year . '-01-01';
190
-		$holescores = Holescore::with('round.player','hole')
189
+		$year = $year.'-01-01';
190
+		$holescores = Holescore::with('round.player', 'hole')
191 191
 			->where('created_at', '>', $year)
192 192
 			->get();
193 193
 		$allOthers = array();
194
-		foreach($holescores as $key => $holescore) {
195
-			if($holescore['round']['match_id'] != null){
196
-				if( ($holescore['score'] - $holescore['hole']['par']) > 2) {
197
-					$allOthers[]= $holescore['round']['player']['name'];
194
+		foreach ($holescores as $key => $holescore) {
195
+			if ($holescore['round']['match_id'] != null) {
196
+				if (($holescore['score'] - $holescore['hole']['par']) > 2) {
197
+					$allOthers[] = $holescore['round']['player']['name'];
198 198
 				}
199 199
 			}
200 200
 		}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		$others = array();
204 204
 			foreach ($newArray as $key => $value) {
205 205
 				$others[$i]['name'] = $key;
206
-				$others[$i]['others'] =$value;
206
+				$others[$i]['others'] = $value;
207 207
 				$i++;
208 208
 			}
209 209
 		return $others;
Please login to merge, or discard this patch.