|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class EnterScoresController extends \BaseController { |
|
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Display a listing of the resource. |
|
7
|
|
|
* |
|
8
|
|
|
* @return Response |
|
9
|
|
|
*/ |
|
10
|
|
|
public function view() |
|
11
|
|
|
{ |
|
12
|
|
|
/* |
|
|
|
|
|
|
13
|
|
|
foreach (Score::with('player')->get() as $score) { |
|
14
|
|
|
echo $score->player->name . "<br>"; |
|
15
|
|
|
} |
|
16
|
|
|
*/ |
|
17
|
|
|
$holescores = Holescore::with('hole')->where('created_at', '>=', '2015-04-28')->get(); |
|
18
|
|
|
$count = $holescores->count(); |
|
19
|
|
|
|
|
20
|
|
|
$eagles = 0; |
|
21
|
|
|
$birdies = 0; |
|
22
|
|
|
$pars = 0; |
|
23
|
|
|
$bogeys = 0; |
|
24
|
|
|
$doubleBogeys = 0; |
|
25
|
|
|
$triples = 0; |
|
26
|
|
|
$others = 0; |
|
27
|
|
|
$holes = 1; |
|
28
|
|
|
foreach (Holescore::with('hole')->where('created_at', '>=', '2015-04-28')->get() as $holescore) { |
|
29
|
|
|
$diff = ($holescore->score) - ($holescore->hole->par); |
|
30
|
|
|
|
|
31
|
|
|
switch ($diff) { |
|
32
|
|
|
case -2: |
|
33
|
|
|
$eagles++; |
|
34
|
|
|
break; |
|
35
|
|
|
case -1: |
|
36
|
|
|
$birdies++; |
|
37
|
|
|
break; |
|
38
|
|
|
case 0: |
|
39
|
|
|
$pars++; |
|
40
|
|
|
break; |
|
41
|
|
|
case 1: |
|
42
|
|
|
$bogeys++; |
|
43
|
|
|
break; |
|
44
|
|
|
case 2: |
|
45
|
|
|
$doubleBogeys++; |
|
46
|
|
|
break; |
|
47
|
|
|
case 3: |
|
48
|
|
|
$triples++; |
|
49
|
|
|
break; |
|
50
|
|
|
case ($diff > 3): |
|
51
|
|
|
$others++; |
|
52
|
|
|
break; |
|
53
|
|
|
} |
|
54
|
|
|
$holes++; |
|
55
|
|
|
//echo $holescore->hole->number . " score = " . $holescore->score ." " . $diff . "<br>"; |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
echo "Number of holes played by all = " . $count . "<br>"; |
|
59
|
|
|
echo "Number of birdies =" . $birdies . " " . round($birdies/$count,2) . "%<br>"; |
|
60
|
|
|
echo "Number of pars = " . $pars . " " . round($pars/$count,2) . "%<br>"; |
|
61
|
|
|
echo "Number of bogeys =" . $bogeys . " " . round($bogeys/$count,2) . "%<br>"; |
|
62
|
|
|
echo "Number of double bogeys = " . $doubleBogeys . " " . round($doubleBogeys/$count,2) . "%<br>"; |
|
63
|
|
|
echo "Number of triples =" . $triples . " " . round($triples/$count,2) . "%<br>"; |
|
64
|
|
|
echo "Number of others = " . $others . " " . round($others/$count,2) . "%<br>"; |
|
65
|
|
|
exit(); |
|
|
|
|
|
|
66
|
|
|
$scores = Score::where('player_id', '=', 2)->orderBy('date', 'desc')->take(20)->get(); |
|
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
foreach( $scores->id as $scoreId) { |
|
69
|
|
|
$holescores[$score_id] = Holescore::where('score_id', '=', $scoreId)->get(); |
|
70
|
|
|
} |
|
71
|
|
|
return $scores; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Remove the specified resource from storage. |
|
78
|
|
|
* |
|
79
|
|
|
* @param int $id |
|
80
|
|
|
* @return Response |
|
81
|
|
|
*/ |
|
82
|
|
|
public function destroy($id) |
|
83
|
|
|
{ |
|
84
|
|
|
// |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
} |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.