@@ -8,8 +8,7 @@ discard block |
||
| 8 | 8 | use \Holescore; |
| 9 | 9 | use \Match; |
| 10 | 10 | |
| 11 | -class LeagueStatisticsEloquent implements LeagueStatistics |
|
| 12 | -{ |
|
| 11 | +class LeagueStatisticsEloquent implements LeagueStatistics { |
|
| 13 | 12 | public function topFiveLowestScores() |
| 14 | 13 | { |
| 15 | 14 | return Round::with('player','course')->orderBy('score')->take(5)->get(); |
@@ -87,16 +86,18 @@ discard block |
||
| 87 | 86 | array_multisort($skinsCount, SORT_DESC); |
| 88 | 87 | return $skinsCount; |
| 89 | 88 | } |
| 90 | - public function totalEagles($year){} |
|
| 89 | + public function totalEagles($year) |
|
| 90 | + { |
|
| 91 | +} |
|
| 91 | 92 | public function totalBirdies($year) |
| 92 | - { |
|
| 93 | + { |
|
| 93 | 94 | $year = $year . '-01-01'; |
| 94 | 95 | $holescores = Holescore::with('round.player','hole') |
| 95 | 96 | ->where('created_at', '>', $year) |
| 96 | 97 | ->get(); |
| 97 | 98 | $allBirdies = array(); |
| 98 | 99 | foreach($holescores as $key => $holescore) { |
| 99 | - if($holescore['round']['match_id'] != null){ |
|
| 100 | + if($holescore['round']['match_id'] != null) { |
|
| 100 | 101 | if( ($holescore['hole']['par'] - $holescore['score']) === 1) { |
| 101 | 102 | $allBirdies[]= $holescore['round']['player']['name']; |
| 102 | 103 | } |
@@ -113,14 +114,14 @@ discard block |
||
| 113 | 114 | return $birds; |
| 114 | 115 | } |
| 115 | 116 | public function totalPars($year) |
| 116 | - { |
|
| 117 | + { |
|
| 117 | 118 | $year = $year . '-01-01'; |
| 118 | 119 | $holescores = Holescore::with('round.player','hole') |
| 119 | 120 | ->where('created_at', '>', $year) |
| 120 | 121 | ->get(); |
| 121 | 122 | $allPars = array(); |
| 122 | 123 | foreach($holescores as $key => $holescore) { |
| 123 | - if($holescore['round']['match_id'] != null){ |
|
| 124 | + if($holescore['round']['match_id'] != null) { |
|
| 124 | 125 | if( ($holescore['hole']['par'] - $holescore['score']) === 0) { |
| 125 | 126 | $allPars[]= $holescore['round']['player']['name']; |
| 126 | 127 | } |
@@ -137,14 +138,14 @@ discard block |
||
| 137 | 138 | return $pars; |
| 138 | 139 | } |
| 139 | 140 | public function totalBogeys($year) |
| 140 | - { |
|
| 141 | + { |
|
| 141 | 142 | $year = $year . '-01-01'; |
| 142 | 143 | $holescores = Holescore::with('round.player','hole') |
| 143 | 144 | ->where('created_at', '>', $year) |
| 144 | 145 | ->get(); |
| 145 | 146 | $allBogeys = array(); |
| 146 | 147 | foreach($holescores as $key => $holescore) { |
| 147 | - if($holescore['round']['match_id'] != null){ |
|
| 148 | + if($holescore['round']['match_id'] != null) { |
|
| 148 | 149 | if( ($holescore['score'] - $holescore['hole']['par']) === 1) { |
| 149 | 150 | $allBogeys[]= $holescore['round']['player']['name']; |
| 150 | 151 | } |
@@ -161,14 +162,14 @@ discard block |
||
| 161 | 162 | return $bogeys; |
| 162 | 163 | } |
| 163 | 164 | public function totalDoubles($year) |
| 164 | - { |
|
| 165 | + { |
|
| 165 | 166 | $year = $year . '-01-01'; |
| 166 | 167 | $holescores = Holescore::with('round.player','hole') |
| 167 | 168 | ->where('created_at', '>', $year) |
| 168 | 169 | ->get(); |
| 169 | 170 | $allDoubles = array(); |
| 170 | 171 | foreach($holescores as $key => $holescore) { |
| 171 | - if($holescore['round']['match_id'] != null){ |
|
| 172 | + if($holescore['round']['match_id'] != null) { |
|
| 172 | 173 | if( ($holescore['score'] - $holescore['hole']['par']) === 2) { |
| 173 | 174 | $allDoubles[]= $holescore['round']['player']['name']; |
| 174 | 175 | } |
@@ -185,14 +186,14 @@ discard block |
||
| 185 | 186 | return $doubles; |
| 186 | 187 | } |
| 187 | 188 | public function totalOthers($year) |
| 188 | - { |
|
| 189 | + { |
|
| 189 | 190 | $year = $year . '-01-01'; |
| 190 | 191 | $holescores = Holescore::with('round.player','hole') |
| 191 | 192 | ->where('created_at', '>', $year) |
| 192 | 193 | ->get(); |
| 193 | 194 | $allOthers = array(); |
| 194 | 195 | foreach($holescores as $key => $holescore) { |
| 195 | - if($holescore['round']['match_id'] != null){ |
|
| 196 | + if($holescore['round']['match_id'] != null) { |
|
| 196 | 197 | if( ($holescore['score'] - $holescore['hole']['par']) > 2) { |
| 197 | 198 | $allOthers[]= $holescore['round']['player']['name']; |
| 198 | 199 | } |
@@ -221,7 +222,7 @@ discard block |
||
| 221 | 222 | $rounds->map(function($round) |
| 222 | 223 | { |
| 223 | 224 | $playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get(); |
| 224 | - foreach($playerMatch as $player){ |
|
| 225 | + foreach($playerMatch as $player) { |
|
| 225 | 226 | $handicap = $player['pivot']['handicap']; |
| 226 | 227 | $round->handicap = $handicap; |
| 227 | 228 | } |
@@ -268,7 +269,7 @@ discard block |
||
| 268 | 269 | $rounds->map(function($round) |
| 269 | 270 | { |
| 270 | 271 | $playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get(); |
| 271 | - foreach($playerMatch as $player){ |
|
| 272 | + foreach($playerMatch as $player) { |
|
| 272 | 273 | $handicap = $player['pivot']['handicap']; |
| 273 | 274 | $round->handicap = $handicap; |
| 274 | 275 | } |
@@ -305,7 +306,7 @@ discard block |
||
| 305 | 306 | $players = Player::all(); |
| 306 | 307 | |
| 307 | 308 | $netScores = new \Illuminate\Support\Collection(); |
| 308 | - foreach($players as $player){ |
|
| 309 | + foreach($players as $player) { |
|
| 309 | 310 | $netScores->push($this->netScoresByPlayer($player->id)); |
| 310 | 311 | } |
| 311 | 312 | return $netScores; |
@@ -317,9 +318,9 @@ discard block |
||
| 317 | 318 | $players = Player::all(); |
| 318 | 319 | |
| 319 | 320 | $netScores = new \Illuminate\Support\Collection(); |
| 320 | - foreach($players as $player){ |
|
| 321 | + foreach($players as $player) { |
|
| 321 | 322 | $netScore = $this->netScoresByPlayerTop($player->id, $number); |
| 322 | - if(!$netScore->isEmpty()){ |
|
| 323 | + if(!$netScore->isEmpty()) { |
|
| 323 | 324 | $netScores->push($netScore); |
| 324 | 325 | } |
| 325 | 326 | } |
@@ -332,7 +333,7 @@ discard block |
||
| 332 | 333 | $players = Player::all(); |
| 333 | 334 | |
| 334 | 335 | $netScores = new \Illuminate\Support\Collection(); |
| 335 | - foreach($players as $player){ |
|
| 336 | + foreach($players as $player) { |
|
| 336 | 337 | $netScores->push($this->netScoresByPlayerYear($player->id,$year)); |
| 337 | 338 | } |
| 338 | 339 | return $netScores; |
@@ -343,9 +344,9 @@ discard block |
||
| 343 | 344 | $players = Player::all(); |
| 344 | 345 | |
| 345 | 346 | $netScores = new \Illuminate\Support\Collection(); |
| 346 | - foreach($players as $player){ |
|
| 347 | + foreach($players as $player) { |
|
| 347 | 348 | $netScore = $this->netScoresByPlayerTopYear($player->id, $top, $year); |
| 348 | - if(!$netScore->isEmpty()){ |
|
| 349 | + if(!$netScore->isEmpty()) { |
|
| 349 | 350 | $netScores->push($netScore); |
| 350 | 351 | } |
| 351 | 352 | } |
@@ -359,7 +360,7 @@ discard block |
||
| 359 | 360 | $players = Player::all(); |
| 360 | 361 | |
| 361 | 362 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
| 362 | - foreach($players as $player){ |
|
| 363 | + foreach($players as $player) { |
|
| 363 | 364 | $cumulativeNetScores->push($this->netCumulativeByPlayer($player->id)); |
| 364 | 365 | } |
| 365 | 366 | return $cumulativeNetScores; |
@@ -370,9 +371,9 @@ discard block |
||
| 370 | 371 | $players = Player::all(); |
| 371 | 372 | |
| 372 | 373 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
| 373 | - foreach($players as $player){ |
|
| 374 | + foreach($players as $player) { |
|
| 374 | 375 | $netScore = $this->netCumulativeByPlayerTop($player->id, $top); |
| 375 | - if($netScore->isEmpty() == false){ |
|
| 376 | + if($netScore->isEmpty() == false) { |
|
| 376 | 377 | $cumulativeNetScores->push($netScore); |
| 377 | 378 | } |
| 378 | 379 | } |
@@ -384,7 +385,7 @@ discard block |
||
| 384 | 385 | $netScores = $this->netScoresByPlayer($playerId); |
| 385 | 386 | $cumulativeNet= new \Illuminate\Support\Collection(); |
| 386 | 387 | |
| 387 | - if($netScores->count() > 0){ |
|
| 388 | + if($netScores->count() > 0) { |
|
| 388 | 389 | $netScore = $netScores->first(); |
| 389 | 390 | |
| 390 | 391 | $totalNetScore = $netScores->sum('netScore'); |
@@ -400,7 +401,7 @@ discard block |
||
| 400 | 401 | $netScores = $this->netScoresByPlayerTop($playerId, $top); |
| 401 | 402 | $cumulativeNet= new \Illuminate\Support\Collection(); |
| 402 | 403 | |
| 403 | - if($netScores->count() > 0){ |
|
| 404 | + if($netScores->count() > 0) { |
|
| 404 | 405 | $netScore = $netScores->first(); |
| 405 | 406 | |
| 406 | 407 | $totalNetScore = $netScores->sum('netScore'); |
@@ -417,7 +418,7 @@ discard block |
||
| 417 | 418 | $players = Player::all(); |
| 418 | 419 | |
| 419 | 420 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
| 420 | - foreach($players as $player){ |
|
| 421 | + foreach($players as $player) { |
|
| 421 | 422 | $cumulativeNetScores->push($this->netCumulativeByPlayerYear($player->id,$year)); |
| 422 | 423 | } |
| 423 | 424 | return $cumulativeNetScores; |
@@ -428,9 +429,9 @@ discard block |
||
| 428 | 429 | $players = Player::all(); |
| 429 | 430 | |
| 430 | 431 | $cumulativeNetScores = new \Illuminate\Support\Collection(); |
| 431 | - foreach($players as $player){ |
|
| 432 | + foreach($players as $player) { |
|
| 432 | 433 | $netScore = $this->netCumulativeByPlayerTopYear($player->id, $top, $year); |
| 433 | - if($netScore->isEmpty() == false){ |
|
| 434 | + if($netScore->isEmpty() == false) { |
|
| 434 | 435 | $cumulativeNetScores->push($netScore); |
| 435 | 436 | } |
| 436 | 437 | } |
@@ -442,7 +443,7 @@ discard block |
||
| 442 | 443 | $netScores = $this->netScoresByPlayerYear($playerId, $year); |
| 443 | 444 | $cumulativeNet= new \Illuminate\Support\Collection(); |
| 444 | 445 | |
| 445 | - if($netScores->count() > 0){ |
|
| 446 | + if($netScores->count() > 0) { |
|
| 446 | 447 | $netScore = $netScores->first(); |
| 447 | 448 | |
| 448 | 449 | $totalNetScore = $netScores->sum('netScore'); |
@@ -458,7 +459,7 @@ discard block |
||
| 458 | 459 | $netScores = $this->netScoresByPlayerTopYear($playerId, $top, $year); |
| 459 | 460 | $cumulativeNet= new \Illuminate\Support\Collection(); |
| 460 | 461 | |
| 461 | - if($netScores->count() > 0){ |
|
| 462 | + if($netScores->count() > 0) { |
|
| 462 | 463 | $netScore = $netScores->first(); |
| 463 | 464 | |
| 464 | 465 | $totalNetScore = $netScores->sum('netScore'); |