| @@ 91-114 (lines=24) @@ | ||
| 88 | return $skinsCount; |
|
| 89 | } |
|
| 90 | public function totalEagles($year){} |
|
| 91 | public function totalBirdies($year) |
|
| 92 | { |
|
| 93 | $year = $year . '-01-01'; |
|
| 94 | $holescores = Holescore::with('round.player','hole') |
|
| 95 | ->where('created_at', '>', $year) |
|
| 96 | ->get(); |
|
| 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']; |
|
| 102 | } |
|
| 103 | } |
|
| 104 | } |
|
| 105 | $i =0; |
|
| 106 | $newArray = array_count_values($allBirdies); |
|
| 107 | $birds = array(); |
|
| 108 | foreach ($newArray as $key => $value) { |
|
| 109 | $birds[$i]['name'] = $key; |
|
| 110 | $birds[$i]['birds'] =$value; |
|
| 111 | $i++; |
|
| 112 | } |
|
| 113 | return $birds; |
|
| 114 | } |
|
| 115 | public function totalPars($year) |
|
| 116 | { |
|
| 117 | $year = $year . '-01-01'; |
|
| @@ 115-138 (lines=24) @@ | ||
| 112 | } |
|
| 113 | return $birds; |
|
| 114 | } |
|
| 115 | public function totalPars($year) |
|
| 116 | { |
|
| 117 | $year = $year . '-01-01'; |
|
| 118 | $holescores = Holescore::with('round.player','hole') |
|
| 119 | ->where('created_at', '>', $year) |
|
| 120 | ->get(); |
|
| 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']; |
|
| 126 | } |
|
| 127 | } |
|
| 128 | } |
|
| 129 | $i =0; |
|
| 130 | $newArray = array_count_values($allPars); |
|
| 131 | $pars = array(); |
|
| 132 | foreach ($newArray as $key => $value) { |
|
| 133 | $pars[$i]['name'] = $key; |
|
| 134 | $pars[$i]['pars'] =$value; |
|
| 135 | $i++; |
|
| 136 | } |
|
| 137 | return $pars; |
|
| 138 | } |
|
| 139 | public function totalBogeys($year) |
|
| 140 | { |
|
| 141 | $year = $year . '-01-01'; |
|
| @@ 139-162 (lines=24) @@ | ||
| 136 | } |
|
| 137 | return $pars; |
|
| 138 | } |
|
| 139 | public function totalBogeys($year) |
|
| 140 | { |
|
| 141 | $year = $year . '-01-01'; |
|
| 142 | $holescores = Holescore::with('round.player','hole') |
|
| 143 | ->where('created_at', '>', $year) |
|
| 144 | ->get(); |
|
| 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']; |
|
| 150 | } |
|
| 151 | } |
|
| 152 | } |
|
| 153 | $i = 0; |
|
| 154 | $newArray = array_count_values($allBogeys); |
|
| 155 | $bogeys = array(); |
|
| 156 | foreach ($newArray as $key => $value) { |
|
| 157 | $bogeys[$i]['name'] = $key; |
|
| 158 | $bogeys[$i]['bogeys'] =$value; |
|
| 159 | $i++; |
|
| 160 | } |
|
| 161 | return $bogeys; |
|
| 162 | } |
|
| 163 | public function totalDoubles($year) |
|
| 164 | { |
|
| 165 | $year = $year . '-01-01'; |
|
| @@ 163-186 (lines=24) @@ | ||
| 160 | } |
|
| 161 | return $bogeys; |
|
| 162 | } |
|
| 163 | public function totalDoubles($year) |
|
| 164 | { |
|
| 165 | $year = $year . '-01-01'; |
|
| 166 | $holescores = Holescore::with('round.player','hole') |
|
| 167 | ->where('created_at', '>', $year) |
|
| 168 | ->get(); |
|
| 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']; |
|
| 174 | } |
|
| 175 | } |
|
| 176 | } |
|
| 177 | $i = 0; |
|
| 178 | $newArray = array_count_values($allDoubles); |
|
| 179 | $doubles = array(); |
|
| 180 | foreach ($newArray as $key => $value) { |
|
| 181 | $doubles[$i]['name'] = $key; |
|
| 182 | $doubles[$i]['doubles'] =$value; |
|
| 183 | $i++; |
|
| 184 | } |
|
| 185 | return $doubles; |
|
| 186 | } |
|
| 187 | public function totalOthers($year) |
|
| 188 | { |
|
| 189 | $year = $year . '-01-01'; |
|
| @@ 187-210 (lines=24) @@ | ||
| 184 | } |
|
| 185 | return $doubles; |
|
| 186 | } |
|
| 187 | public function totalOthers($year) |
|
| 188 | { |
|
| 189 | $year = $year . '-01-01'; |
|
| 190 | $holescores = Holescore::with('round.player','hole') |
|
| 191 | ->where('created_at', '>', $year) |
|
| 192 | ->get(); |
|
| 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']; |
|
| 198 | } |
|
| 199 | } |
|
| 200 | } |
|
| 201 | $i = 0; |
|
| 202 | $newArray = array_count_values($allOthers); |
|
| 203 | $others = array(); |
|
| 204 | foreach ($newArray as $key => $value) { |
|
| 205 | $others[$i]['name'] = $key; |
|
| 206 | $others[$i]['others'] =$value; |
|
| 207 | $i++; |
|
| 208 | } |
|
| 209 | return $others; |
|
| 210 | } |
|
| 211 | ||
| 212 | public function netScoresByPlayer($playerId) |
|
| 213 | { |
|