|
1
|
|
|
<?php namespace GolfLeague\Storage\MatchRound; |
|
2
|
|
|
|
|
3
|
|
|
use \Match as Match; |
|
4
|
|
|
use \Round as Round; |
|
5
|
|
|
use \Player as Player; |
|
6
|
|
|
|
|
7
|
|
|
class EloquentMatchRoundRepository implements MatchRoundRepository |
|
8
|
|
|
{ |
|
9
|
|
|
/*Return Score collections that include: |
|
10
|
|
|
* Player Name |
|
11
|
|
|
* Date |
|
12
|
|
|
* Total |
|
13
|
|
|
* Course |
|
14
|
|
|
* Multideminsional Array of Hole Numbers and scores |
|
15
|
|
|
**/ |
|
16
|
|
|
|
|
17
|
|
|
//Retrieve all rounds associated with a match with holescores |
|
18
|
|
|
public function all() |
|
19
|
|
|
{ |
|
20
|
|
|
return Round::with('player', 'holescores')->whereNotNull('match_id')->get(); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
// Retrieve Rounds of a match with holescores |
|
24
|
|
|
// Return data is sorted by the order of the holes of the round |
|
25
|
|
|
public function getByMatch($matchid) |
|
26
|
|
|
{ |
|
27
|
|
|
return Round::with('player', 'holescores')->where('match_id', '=', $matchid)->get(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function create($matchdata) |
|
31
|
|
|
{ |
|
32
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function matchGroup($matchid, $group) |
|
36
|
|
|
{ |
|
37
|
|
|
$players = Match::find($matchid)->players()->where('match_player.group','=',$group)->get(); |
|
38
|
|
|
foreach($players as $key => $player) { |
|
39
|
|
|
$rounds = Round::with('holescores', 'course.holes')->where('player_id', '=', $player->id)->where('match_id', '=', $matchid)->get(); |
|
40
|
|
|
$players[$key]['round'] = $rounds; |
|
41
|
|
|
} |
|
42
|
|
|
return $players; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getMatchData($matchid) |
|
46
|
|
|
{ |
|
47
|
|
|
$match = Match::find($matchid)->players()->where('match_player.match_id','=', $matchid)->get(); |
|
48
|
|
|
return $match; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function getMatchPlayerHandicap($matchid, $playerId) |
|
52
|
|
|
{ |
|
53
|
|
|
$players = Player::find($playerId)->matches()->where('match_player.match_id','=', $matchid)->get(); |
|
54
|
|
|
foreach($players as $player){ |
|
55
|
|
|
$handicap = $player['pivot']['handicap']; |
|
56
|
|
|
} |
|
57
|
|
|
return $handicap; |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: