Completed
Push — master ( c5f67f...8d1146 )
by Michael
03:07
created
app/library/Classes/Statistics/PlayerStatisticsEloquent.php 1 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.
app/library/Classes/Statistics/LeagueStatisticsEloquent.php 1 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.