@@ -16,23 +16,23 @@ |
||
| 16 | 16 | public function totalOthers($year); |
| 17 | 17 | |
| 18 | 18 | public function netScoresByPlayer($playerId); |
| 19 | - public function netScoresByPlayerTop($playerId,$number); |
|
| 19 | + public function netScoresByPlayerTop($playerId, $number); |
|
| 20 | 20 | public function netScoresByPlayerYear($playerId, $year); |
| 21 | - public function netScoresByPlayerTopYear($playerId,$top, $year); |
|
| 21 | + public function netScoresByPlayerTopYear($playerId, $top, $year); |
|
| 22 | 22 | |
| 23 | 23 | public function netScoresLeague(); |
| 24 | 24 | public function netScoresLeagueTop($number); |
| 25 | 25 | public function netScoresLeagueYear($year); |
| 26 | - public function netScoresLeagueTopYear($top,$year); |
|
| 26 | + public function netScoresLeagueTopYear($top, $year); |
|
| 27 | 27 | |
| 28 | 28 | // Cumulative Net returns +/- relative to par |
| 29 | 29 | public function netCumulative(); |
| 30 | 30 | public function netCumulativeTop($top); |
| 31 | 31 | public function netCumulativeByPlayer($playerId); |
| 32 | - public function netCumulativeByPlayerTop($playerId,$top); |
|
| 32 | + public function netCumulativeByPlayerTop($playerId, $top); |
|
| 33 | 33 | public function netCumulativeYear($year); |
| 34 | - public function netCumulativeTopYear($top,$year); |
|
| 35 | - public function netCumulativeByPlayerYear($playerId,$year); |
|
| 36 | - public function netCumulativeByPlayerTopYear($playerId,$top,$year); |
|
| 34 | + public function netCumulativeTopYear($top, $year); |
|
| 35 | + public function netCumulativeByPlayerYear($playerId, $year); |
|
| 36 | + public function netCumulativeByPlayerTopYear($playerId, $top, $year); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function __construct(RoundRepository $roundRepo) |
| 28 | 28 | { |
| 29 | - $this->roundRepo= $roundRepo; |
|
| 29 | + $this->roundRepo = $roundRepo; |
|
| 30 | 30 | } // End of __construct |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | $i = 1; |
| 46 | 46 | |
| 47 | 47 | $ctpWinners = Ctp::where('match_id', '=', $match->id)->get(); |
| 48 | - foreach($ctpWinners as $key => $ctpWinner){ |
|
| 48 | + foreach ($ctpWinners as $key => $ctpWinner) { |
|
| 49 | 49 | $playerExists = $this->recursive_array_search($ctpWinner->player_id, $winningPlayers); |
| 50 | 50 | //if player is already there add money here to other money |
| 51 | - if($playerExists){ |
|
| 51 | + if ($playerExists) { |
|
| 52 | 52 | $winningPlayers[$i]['player_id'] = $ctpWinner->player_id; |
| 53 | 53 | $winningPlayers[$i]['money'] = ($ctpWinner->money + $winningPlayers[$playerExists]['money']); |
| 54 | 54 | unset($winningPlayers[$playerExists]); |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $netWinners = Netwinner::where('match_id', '=', $match->id)->get(); |
| 64 | - foreach($netWinners as $key => $netWinner){ |
|
| 64 | + foreach ($netWinners as $key => $netWinner) { |
|
| 65 | 65 | $playerExists = $this->recursive_array_search($netWinner->player_id, $winningPlayers); |
| 66 | 66 | //if player is already there add money here to other money |
| 67 | - if($playerExists){ |
|
| 67 | + if ($playerExists) { |
|
| 68 | 68 | $winningPlayers[$i]['player_id'] = $netWinner->player_id; |
| 69 | 69 | $winningPlayers[$i]['money'] = ($netWinner->money + $winningPlayers[$playerExists]['money']); |
| 70 | 70 | unset($winningPlayers[$playerExists]); |
| 71 | 71 | } |
| 72 | - else{ |
|
| 72 | + else { |
|
| 73 | 73 | $winningPlayers[$i]['player_id'] = $netWinner->player_id; |
| 74 | 74 | $winningPlayers[$i]['money'] = $netWinner->money; |
| 75 | 75 | } |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $grossWinners = Grosswinner::where('match_id', '=', $match->id)->get(); |
| 80 | - foreach($grossWinners as $key => $grossWinner){ |
|
| 80 | + foreach ($grossWinners as $key => $grossWinner) { |
|
| 81 | 81 | $playerExists = $this->recursive_array_search($grossWinner->player_id, $winningPlayers); |
| 82 | 82 | //if player is already there add money here to other money |
| 83 | - if($playerExists){ |
|
| 83 | + if ($playerExists) { |
|
| 84 | 84 | $winningPlayers[$i]['player_id'] = $grossWinner->player_id; |
| 85 | 85 | $winningPlayers[$i]['money'] = ($grossWinner->money + $winningPlayers[$playerExists]['money']); |
| 86 | 86 | unset($winningPlayers[$playerExists]); |
| 87 | 87 | } |
| 88 | - else{ |
|
| 88 | + else { |
|
| 89 | 89 | $winningPlayers[$i]['player_id'] = $grossWinner->player_id; |
| 90 | 90 | $winningPlayers[$i]['money'] = $grossWinner->money; |
| 91 | 91 | } |
@@ -93,15 +93,15 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $skinWinners = Skin::where('match_id', '=', $match->id)->get(); |
| 96 | - foreach($skinWinners as $key => $skinWinner){ |
|
| 96 | + foreach ($skinWinners as $key => $skinWinner) { |
|
| 97 | 97 | $playerExists = $this->recursive_array_search($skinWinner->player_id, $winningPlayers); |
| 98 | 98 | //if player is already there add money here to other money |
| 99 | - if($playerExists){ |
|
| 99 | + if ($playerExists) { |
|
| 100 | 100 | $winningPlayers[$i]['player_id'] = $skinWinner->player_id; |
| 101 | 101 | $winningPlayers[$i]['money'] = ($skinWinner->money + $winningPlayers[$playerExists]['money']); |
| 102 | 102 | unset($winningPlayers[$playerExists]); |
| 103 | 103 | } |
| 104 | - else{ |
|
| 104 | + else { |
|
| 105 | 105 | $winningPlayers[$i]['player_id'] = $skinWinner->player_id; |
| 106 | 106 | $winningPlayers[$i]['money'] = $skinWinner->money; |
| 107 | 107 | } |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | //Consolidate any multiple instances of a player |
| 112 | - foreach ($winningPlayers as $key => $winningPlayer){ |
|
| 112 | + foreach ($winningPlayers as $key => $winningPlayer) { |
|
| 113 | 113 | array_search($winningPlayer['player_id'], $winningPlayers); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - foreach ($winningPlayers as $key => $player){ |
|
| 116 | + foreach ($winningPlayers as $key => $player) { |
|
| 117 | 117 | $currentPlayer = Player::find($player['player_id']); |
| 118 | 118 | $attributes = array( |
| 119 | 119 | "winnings" => $player['money'] |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | $events->listen('match.finalize', 'GolfLeague\Handlers\FinalizeHandler'); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public function recursive_array_search($needle,$haystack) { |
|
| 139 | - foreach($haystack as $key=>$value) { |
|
| 140 | - $current_key=$key; |
|
| 141 | - if($needle===$value || (is_array($value) && $this->recursive_array_search($needle,$value) !== false)) { |
|
| 138 | + public function recursive_array_search($needle, $haystack) { |
|
| 139 | + foreach ($haystack as $key=>$value) { |
|
| 140 | + $current_key = $key; |
|
| 141 | + if ($needle === $value || (is_array($value) && $this->recursive_array_search($needle, $value) !== false)) { |
|
| 142 | 142 | return $current_key; |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function show($id) |
| 31 | 31 | { |
| 32 | - $results = $this->leagueStatistics->totalEagles($id); |
|
| 32 | + $results = $this->leagueStatistics->totalEagles($id); |
|
| 33 | 33 | $data['data'] = $results; |
| 34 | 34 | return $data; |
| 35 | 35 | } |
@@ -17,7 +17,7 @@ |
||
| 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 | |
@@ -14,7 +14,7 @@ |
||
| 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 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -15,7 +15,7 @@ |
||
| 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 | } |
@@ -13,13 +13,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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'); |
@@ -50,7 +50,7 @@ |
||
| 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 | |