@@ -41,7 +41,6 @@ |
||
| 41 | 41 | /** |
| 42 | 42 | * Display the specified resource. |
| 43 | 43 | * |
| 44 | - * @param int $course_id |
|
| 45 | 44 | * @return Response |
| 46 | 45 | */ |
| 47 | 46 | public function show() |
@@ -3,10 +3,10 @@ discard block |
||
| 3 | 3 | class HolesController extends \BaseController { |
| 4 | 4 | |
| 5 | 5 | public function __construct(Course $course, Hole $hole) |
| 6 | - { |
|
| 6 | + { |
|
| 7 | 7 | $this->course = $course; |
| 8 | 8 | $this->hole = $hole; |
| 9 | - } |
|
| 9 | + } |
|
| 10 | 10 | /** |
| 11 | 11 | * Display a listing of the resource. |
| 12 | 12 | * |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | public function index() |
| 16 | 16 | { |
| 17 | 17 | $data = $this->hole->all(); |
| 18 | - return $data; |
|
| 18 | + return $data; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | class LiveLeaderboardController extends \BaseController { |
| 7 | 7 | |
| 8 | 8 | public function __construct(LeaderboardService $leaderboard) |
| 9 | - { |
|
| 9 | + { |
|
| 10 | 10 | $this->leaderboard = $leaderboard; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | /** |
| 14 | 14 | * Display a listing of the resource. |
| 15 | 15 | * |
| 16 | - * @return Response |
|
| 16 | + * @return string |
|
| 17 | 17 | */ |
| 18 | 18 | public function index() |
| 19 | 19 | { |
@@ -6,11 +6,11 @@ discard block |
||
| 6 | 6 | class LiveLeaderboardController extends \BaseController { |
| 7 | 7 | |
| 8 | 8 | public function __construct(LeaderboardService $leaderboard) |
| 9 | - { |
|
| 10 | - $this->leaderboard = $leaderboard; |
|
| 11 | - } |
|
| 9 | + { |
|
| 10 | + $this->leaderboard = $leaderboard; |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - /** |
|
| 13 | + /** |
|
| 14 | 14 | * Display a listing of the resource. |
| 15 | 15 | * |
| 16 | 16 | * @return Response |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function show($id) |
| 53 | 53 | { |
| 54 | - $match = Input::get('match'); |
|
| 55 | - $type = $id; |
|
| 54 | + $match = Input::get('match'); |
|
| 55 | + $type = $id; |
|
| 56 | 56 | |
| 57 | - //return net or gross leaderboard for live scoring |
|
| 57 | + //return net or gross leaderboard for live scoring |
|
| 58 | 58 | $data['data'] = $this->leaderboard->calculate($match,$type); |
| 59 | - return $data; |
|
| 59 | + return $data; |
|
| 60 | 60 | |
| 61 | 61 | } |
| 62 | 62 | |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | $type = $id; |
| 56 | 56 | |
| 57 | 57 | //return net or gross leaderboard for live scoring |
| 58 | - $data['data'] = $this->leaderboard->calculate($match,$type); |
|
| 58 | + $data['data'] = $this->leaderboard->calculate($match, $type); |
|
| 59 | 59 | return $data; |
| 60 | 60 | |
| 61 | 61 | } |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | class LiveLeaderboardController extends \BaseController { |
| 7 | 7 | |
| 8 | 8 | public function __construct(LeaderboardService $leaderboard) |
| 9 | - { |
|
| 9 | + { |
|
| 10 | 10 | $this->leaderboard = $leaderboard; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -43,7 +43,6 @@ |
||
| 43 | 43 | /** |
| 44 | 44 | * Show the form for editing the specified resource. |
| 45 | 45 | * |
| 46 | - * @param int $id |
|
| 47 | 46 | * @return Response |
| 48 | 47 | */ |
| 49 | 48 | public function edit() |
@@ -4,10 +4,10 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class PlayersController extends \BaseController { |
| 6 | 6 | |
| 7 | - public function __construct(PlayerRepo $player) |
|
| 8 | - { |
|
| 9 | - $this->player = $player; |
|
| 10 | - } |
|
| 7 | + public function __construct(PlayerRepo $player) |
|
| 8 | + { |
|
| 9 | + $this->player = $player; |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Get Data for all players |
@@ -19,58 +19,58 @@ discard block |
||
| 19 | 19 | return $this->player->all(); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Store a newly created resource in storage. |
|
| 24 | - * |
|
| 25 | - * @return Response |
|
| 26 | - */ |
|
| 27 | - public function store() |
|
| 28 | - { |
|
| 22 | + /** |
|
| 23 | + * Store a newly created resource in storage. |
|
| 24 | + * |
|
| 25 | + * @return Response |
|
| 26 | + */ |
|
| 27 | + public function store() |
|
| 28 | + { |
|
| 29 | 29 | $this->player->create(Input::get('name'), Input::get('handicap')); |
| 30 | - } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Display the specified resource. |
|
| 34 | - * |
|
| 35 | - * @param int $id |
|
| 36 | - * @return Response |
|
| 37 | - */ |
|
| 38 | - public function show($id) |
|
| 39 | - { |
|
| 40 | - return $this->player->find($id); |
|
| 41 | - } |
|
| 32 | + /** |
|
| 33 | + * Display the specified resource. |
|
| 34 | + * |
|
| 35 | + * @param int $id |
|
| 36 | + * @return Response |
|
| 37 | + */ |
|
| 38 | + public function show($id) |
|
| 39 | + { |
|
| 40 | + return $this->player->find($id); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Show the form for editing the specified resource. |
|
| 45 | - * |
|
| 46 | - * @param int $id |
|
| 47 | - * @return Response |
|
| 48 | - */ |
|
| 49 | - public function edit() |
|
| 50 | - { |
|
| 43 | + /** |
|
| 44 | + * Show the form for editing the specified resource. |
|
| 45 | + * |
|
| 46 | + * @param int $id |
|
| 47 | + * @return Response |
|
| 48 | + */ |
|
| 49 | + public function edit() |
|
| 50 | + { |
|
| 51 | 51 | |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Update the specified resource in storage. |
|
| 56 | - * |
|
| 57 | - * @param int $id |
|
| 58 | - * @return Response |
|
| 59 | - */ |
|
| 60 | - public function update($id) |
|
| 61 | - { |
|
| 62 | - // |
|
| 63 | - } |
|
| 54 | + /** |
|
| 55 | + * Update the specified resource in storage. |
|
| 56 | + * |
|
| 57 | + * @param int $id |
|
| 58 | + * @return Response |
|
| 59 | + */ |
|
| 60 | + public function update($id) |
|
| 61 | + { |
|
| 62 | + // |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Remove the specified resource from storage. |
|
| 67 | - * |
|
| 68 | - * @param int $id |
|
| 69 | - * @return Response |
|
| 70 | - */ |
|
| 71 | - public function destroy($id) |
|
| 72 | - { |
|
| 73 | - // |
|
| 74 | - } |
|
| 65 | + /** |
|
| 66 | + * Remove the specified resource from storage. |
|
| 67 | + * |
|
| 68 | + * @param int $id |
|
| 69 | + * @return Response |
|
| 70 | + */ |
|
| 71 | + public function destroy($id) |
|
| 72 | + { |
|
| 73 | + // |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | } |
| 77 | 77 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * Create a new instance of the MatchHandler |
| 20 | 20 | * |
| 21 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 21 | + * @param RoundRepository $roundRepo |
|
| 22 | 22 | * @return void |
| 23 | 23 | */ |
| 24 | 24 | public function __construct(RoundRepository $roundRepo, HoleScoreRepository $holescoreRepo) |
@@ -30,7 +30,6 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * Create an initial round for each player after a new match is created |
| 32 | 32 | * |
| 33 | - * @param Match $match |
|
| 34 | 33 | * @return void |
| 35 | 34 | */ |
| 36 | 35 | public function handle($holescore) |
@@ -15,47 +15,47 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class HoleScoreHandler |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Create a new instance of the MatchHandler |
|
| 20 | - * |
|
| 21 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function __construct(RoundRepository $roundRepo, HoleScoreRepository $holescoreRepo) |
|
| 25 | - { |
|
| 26 | - $this->roundRepo= $roundRepo; |
|
| 27 | - $this->holescoreRepo = $holescoreRepo; |
|
| 28 | - } // End of __construct |
|
| 18 | + /** |
|
| 19 | + * Create a new instance of the MatchHandler |
|
| 20 | + * |
|
| 21 | + * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function __construct(RoundRepository $roundRepo, HoleScoreRepository $holescoreRepo) |
|
| 25 | + { |
|
| 26 | + $this->roundRepo= $roundRepo; |
|
| 27 | + $this->holescoreRepo = $holescoreRepo; |
|
| 28 | + } // End of __construct |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Create an initial round for each player after a new match is created |
|
| 32 | - * |
|
| 33 | - * @param Match $match |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 36 | - public function handle($holescore) |
|
| 37 | - { |
|
| 38 | - // Update score and esc in round table |
|
| 39 | - $holescores = $this->holescoreRepo->getByRound($holescore->round_id); |
|
| 40 | - $escTotal = 0; |
|
| 41 | - foreach($holescores as $hole) { |
|
| 42 | - $esc = new EquitableStrokeControl($hole); |
|
| 43 | - $escTotal += $esc->calculate(); |
|
| 44 | - } |
|
| 45 | - $round = $this->roundRepo->find($holescore->round_id); |
|
| 46 | - $round->score = $holescores->sum('score'); |
|
| 47 | - $round->esc = $escTotal; |
|
| 48 | - $this->roundRepo->update($round); |
|
| 49 | - } |
|
| 30 | + /** |
|
| 31 | + * Create an initial round for each player after a new match is created |
|
| 32 | + * |
|
| 33 | + * @param Match $match |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | + public function handle($holescore) |
|
| 37 | + { |
|
| 38 | + // Update score and esc in round table |
|
| 39 | + $holescores = $this->holescoreRepo->getByRound($holescore->round_id); |
|
| 40 | + $escTotal = 0; |
|
| 41 | + foreach($holescores as $hole) { |
|
| 42 | + $esc = new EquitableStrokeControl($hole); |
|
| 43 | + $escTotal += $esc->calculate(); |
|
| 44 | + } |
|
| 45 | + $round = $this->roundRepo->find($holescore->round_id); |
|
| 46 | + $round->score = $holescores->sum('score'); |
|
| 47 | + $round->esc = $escTotal; |
|
| 48 | + $this->roundRepo->update($round); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Register the listeners for the subscriber. |
|
| 53 | - * |
|
| 54 | - * @param Illuminate\Events\Dispatcher $events |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function subscribe($events) |
|
| 58 | - { |
|
| 59 | - $events->listen('eloquent.updated: Holescore', 'GolfLeague\Handlers\HoleScoreHandler'); |
|
| 60 | - } |
|
| 51 | + /** |
|
| 52 | + * Register the listeners for the subscriber. |
|
| 53 | + * |
|
| 54 | + * @param Illuminate\Events\Dispatcher $events |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function subscribe($events) |
|
| 58 | + { |
|
| 59 | + $events->listen('eloquent.updated: Holescore', 'GolfLeague\Handlers\HoleScoreHandler'); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct(RoundRepository $roundRepo, HoleScoreRepository $holescoreRepo) |
| 25 | 25 | { |
| 26 | - $this->roundRepo= $roundRepo; |
|
| 26 | + $this->roundRepo = $roundRepo; |
|
| 27 | 27 | $this->holescoreRepo = $holescoreRepo; |
| 28 | 28 | } // End of __construct |
| 29 | 29 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | // Update score and esc in round table |
| 39 | 39 | $holescores = $this->holescoreRepo->getByRound($holescore->round_id); |
| 40 | 40 | $escTotal = 0; |
| 41 | - foreach($holescores as $hole) { |
|
| 41 | + foreach ($holescores as $hole) { |
|
| 42 | 42 | $esc = new EquitableStrokeControl($hole); |
| 43 | 43 | $escTotal += $esc->calculate(); |
| 44 | 44 | } |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * @author Michael Schmidt |
| 15 | 15 | */ |
| 16 | -class HoleScoreHandler |
|
| 17 | -{ |
|
| 16 | +class HoleScoreHandler { |
|
| 18 | 17 | /** |
| 19 | 18 | * Create a new instance of the MatchHandler |
| 20 | 19 | * |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * Create a new instance of the MatchHandler |
| 19 | 19 | * |
| 20 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 20 | + * @param RoundRepository $roundRepo |
|
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | 23 | public function __construct(RoundRepository $roundRepo) |
@@ -14,51 +14,51 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class MatchHandler |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Create a new instance of the MatchHandler |
|
| 19 | - * |
|
| 20 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function __construct(RoundRepository $roundRepo) |
|
| 24 | - { |
|
| 25 | - $this->roundRepo= $roundRepo; |
|
| 26 | - } // End of __construct |
|
| 17 | + /** |
|
| 18 | + * Create a new instance of the MatchHandler |
|
| 19 | + * |
|
| 20 | + * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function __construct(RoundRepository $roundRepo) |
|
| 24 | + { |
|
| 25 | + $this->roundRepo= $roundRepo; |
|
| 26 | + } // End of __construct |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Create an initial round for each player after a new match is created |
|
| 30 | - * |
|
| 31 | - * @param Match $match |
|
| 32 | - * @return void |
|
| 33 | - */ |
|
| 34 | - public function handle($match) |
|
| 35 | - { |
|
| 36 | - //for each player create an initial round |
|
| 37 | - //var_dump($holescore); |
|
| 38 | - $input = array( |
|
| 39 | - 'date' => $match['date'], |
|
| 40 | - // use holescore->round_id to get all holescores for that round |
|
| 41 | - 'course_id' => $match['course'], |
|
| 28 | + /** |
|
| 29 | + * Create an initial round for each player after a new match is created |
|
| 30 | + * |
|
| 31 | + * @param Match $match |
|
| 32 | + * @return void |
|
| 33 | + */ |
|
| 34 | + public function handle($match) |
|
| 35 | + { |
|
| 36 | + //for each player create an initial round |
|
| 37 | + //var_dump($holescore); |
|
| 38 | + $input = array( |
|
| 39 | + 'date' => $match['date'], |
|
| 40 | + // use holescore->round_id to get all holescores for that round |
|
| 41 | + 'course_id' => $match['course'], |
|
| 42 | 42 | |
| 43 | - 'match_id' => $match['match_id'], |
|
| 44 | - 'score' => 0, |
|
| 45 | - 'esc' =>0 |
|
| 46 | - ); |
|
| 47 | - foreach($match['player'] as $player){ |
|
| 48 | - $input['player_id'] = $player['player_id']; |
|
| 49 | - $this->roundRepo->create($input); |
|
| 43 | + 'match_id' => $match['match_id'], |
|
| 44 | + 'score' => 0, |
|
| 45 | + 'esc' =>0 |
|
| 46 | + ); |
|
| 47 | + foreach($match['player'] as $player){ |
|
| 48 | + $input['player_id'] = $player['player_id']; |
|
| 49 | + $this->roundRepo->create($input); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Register the listeners for the subscriber. |
|
| 56 | - * |
|
| 57 | - * @param Illuminate\Events\Dispatcher $events |
|
| 58 | - * @return array |
|
| 59 | - */ |
|
| 60 | - public function subscribe($events) |
|
| 61 | - { |
|
| 62 | - $events->listen('match.create', 'GolfLeague\Handlers\MatchHandler'); |
|
| 63 | - } |
|
| 54 | + /** |
|
| 55 | + * Register the listeners for the subscriber. |
|
| 56 | + * |
|
| 57 | + * @param Illuminate\Events\Dispatcher $events |
|
| 58 | + * @return array |
|
| 59 | + */ |
|
| 60 | + public function subscribe($events) |
|
| 61 | + { |
|
| 62 | + $events->listen('match.create', 'GolfLeague\Handlers\MatchHandler'); |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function __construct(RoundRepository $roundRepo) |
| 24 | 24 | { |
| 25 | - $this->roundRepo= $roundRepo; |
|
| 25 | + $this->roundRepo = $roundRepo; |
|
| 26 | 26 | } // End of __construct |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | 'score' => 0, |
| 45 | 45 | 'esc' =>0 |
| 46 | 46 | ); |
| 47 | - foreach($match['player'] as $player){ |
|
| 47 | + foreach ($match['player'] as $player) { |
|
| 48 | 48 | $input['player_id'] = $player['player_id']; |
| 49 | 49 | $this->roundRepo->create($input); |
| 50 | 50 | } |
@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | * @author Michael Schmidt |
| 14 | 14 | */ |
| 15 | -class MatchHandler |
|
| 16 | -{ |
|
| 15 | +class MatchHandler { |
|
| 17 | 16 | /** |
| 18 | 17 | * Create a new instance of the MatchHandler |
| 19 | 18 | * |
@@ -44,7 +43,7 @@ discard block |
||
| 44 | 43 | 'score' => 0, |
| 45 | 44 | 'esc' =>0 |
| 46 | 45 | ); |
| 47 | - foreach($match['player'] as $player){ |
|
| 46 | + foreach($match['player'] as $player) { |
|
| 48 | 47 | $input['player_id'] = $player['player_id']; |
| 49 | 48 | $this->roundRepo->create($input); |
| 50 | 49 | } |
@@ -17,7 +17,6 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * Create a new instance of the MatchHandler |
| 19 | 19 | * |
| 20 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 21 | 20 | * @return void |
| 22 | 21 | */ |
| 23 | 22 | public function __construct(HoleScoreRepository $holescoreRepo) |
@@ -28,7 +27,6 @@ discard block |
||
| 28 | 27 | /** |
| 29 | 28 | * Create an initial round for each player after a new match is created |
| 30 | 29 | * |
| 31 | - * @param Match $match |
|
| 32 | 30 | * @return void |
| 33 | 31 | */ |
| 34 | 32 | public function handle($round) |
@@ -14,47 +14,47 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class RoundHandler |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Create a new instance of the MatchHandler |
|
| 19 | - * |
|
| 20 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function __construct(HoleScoreRepository $holescoreRepo) |
|
| 24 | - { |
|
| 25 | - $this->holescoreRepo= $holescoreRepo; |
|
| 26 | - } // End of __construct |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Create an initial round for each player after a new match is created |
|
| 30 | - * |
|
| 31 | - * @param Match $match |
|
| 32 | - * @return void |
|
| 33 | - */ |
|
| 34 | - public function handle($round) |
|
| 35 | - { |
|
| 36 | - $holes = Hole::where('course_id', '=', $round['course_id'])->get(); |
|
| 37 | - foreach($holes as $hole){ |
|
| 38 | - $input = array( |
|
| 39 | - 'score' => null, |
|
| 40 | - 'hole_id' => $hole->id, |
|
| 41 | - 'round_id' => $round['id'] |
|
| 42 | - ); |
|
| 43 | - $this->holescoreRepo->create($input); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Register the listeners for the subscriber. |
|
| 52 | - * |
|
| 53 | - * @param Illuminate\Events\Dispatcher $events |
|
| 54 | - * @return array |
|
| 55 | - */ |
|
| 56 | - public function subscribe($events) |
|
| 57 | - { |
|
| 58 | - $events->listen('eloquent.created: Round', 'GolfLeague\Handlers\RoundHandler'); |
|
| 59 | - } |
|
| 17 | + /** |
|
| 18 | + * Create a new instance of the MatchHandler |
|
| 19 | + * |
|
| 20 | + * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function __construct(HoleScoreRepository $holescoreRepo) |
|
| 24 | + { |
|
| 25 | + $this->holescoreRepo= $holescoreRepo; |
|
| 26 | + } // End of __construct |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Create an initial round for each player after a new match is created |
|
| 30 | + * |
|
| 31 | + * @param Match $match |
|
| 32 | + * @return void |
|
| 33 | + */ |
|
| 34 | + public function handle($round) |
|
| 35 | + { |
|
| 36 | + $holes = Hole::where('course_id', '=', $round['course_id'])->get(); |
|
| 37 | + foreach($holes as $hole){ |
|
| 38 | + $input = array( |
|
| 39 | + 'score' => null, |
|
| 40 | + 'hole_id' => $hole->id, |
|
| 41 | + 'round_id' => $round['id'] |
|
| 42 | + ); |
|
| 43 | + $this->holescoreRepo->create($input); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Register the listeners for the subscriber. |
|
| 52 | + * |
|
| 53 | + * @param Illuminate\Events\Dispatcher $events |
|
| 54 | + * @return array |
|
| 55 | + */ |
|
| 56 | + public function subscribe($events) |
|
| 57 | + { |
|
| 58 | + $events->listen('eloquent.created: Round', 'GolfLeague\Handlers\RoundHandler'); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function __construct(HoleScoreRepository $holescoreRepo) |
| 24 | 24 | { |
| 25 | - $this->holescoreRepo= $holescoreRepo; |
|
| 25 | + $this->holescoreRepo = $holescoreRepo; |
|
| 26 | 26 | } // End of __construct |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public function handle($round) |
| 35 | 35 | { |
| 36 | 36 | $holes = Hole::where('course_id', '=', $round['course_id'])->get(); |
| 37 | - foreach($holes as $hole){ |
|
| 37 | + foreach ($holes as $hole) { |
|
| 38 | 38 | $input = array( |
| 39 | 39 | 'score' => null, |
| 40 | 40 | 'hole_id' => $hole->id, |
@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | * @author Michael Schmidt |
| 14 | 14 | */ |
| 15 | -class RoundHandler |
|
| 16 | -{ |
|
| 15 | +class RoundHandler { |
|
| 17 | 16 | /** |
| 18 | 17 | * Create a new instance of the MatchHandler |
| 19 | 18 | * |
@@ -34,7 +33,7 @@ discard block |
||
| 34 | 33 | public function handle($round) |
| 35 | 34 | { |
| 36 | 35 | $holes = Hole::where('course_id', '=', $round['course_id'])->get(); |
| 37 | - foreach($holes as $hole){ |
|
| 36 | + foreach($holes as $hole) { |
|
| 38 | 37 | $input = array( |
| 39 | 38 | 'score' => null, |
| 40 | 39 | 'hole_id' => $hole->id, |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Loads our $matchRepo |
| 17 | 17 | * |
| 18 | - * @param MatchRepository $matchRepo |
|
| 18 | + * @param MatchRepository $matchRoundRepo |
|
| 19 | 19 | * @return MatchService |
| 20 | 20 | */ |
| 21 | 21 | public function __construct(MatchRoundRepository $matchRoundRepo, RoundRepository $roundRepo, MatchRepository $match) |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * Method to get match data from input Match id |
| 34 | 34 | * |
| 35 | - * @param mixed $matchdata |
|
| 35 | + * @param mixed $matchId |
|
| 36 | 36 | * @return JSON object |
| 37 | 37 | */ |
| 38 | 38 | public function getByMatch($matchId) |
@@ -9,41 +9,41 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class MatchRoundService |
| 11 | 11 | { |
| 12 | - // Containing our pokemonRepository to make all our database calls to |
|
| 13 | - protected $matchRepo; |
|
| 12 | + // Containing our pokemonRepository to make all our database calls to |
|
| 13 | + protected $matchRepo; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Loads our $matchRepo |
|
| 17 | - * |
|
| 18 | - * @param MatchRepository $matchRepo |
|
| 19 | - * @return MatchService |
|
| 20 | - */ |
|
| 21 | - public function __construct(MatchRoundRepository $matchRoundRepo, RoundRepository $roundRepo, MatchRepository $match) |
|
| 22 | - { |
|
| 23 | - $this->matchRoundRepo = $matchRoundRepo; |
|
| 24 | - $this->roundRepo = $roundRepo; |
|
| 25 | - $this->match = $match; |
|
| 26 | - } |
|
| 15 | + /** |
|
| 16 | + * Loads our $matchRepo |
|
| 17 | + * |
|
| 18 | + * @param MatchRepository $matchRepo |
|
| 19 | + * @return MatchService |
|
| 20 | + */ |
|
| 21 | + public function __construct(MatchRoundRepository $matchRoundRepo, RoundRepository $roundRepo, MatchRepository $match) |
|
| 22 | + { |
|
| 23 | + $this->matchRoundRepo = $matchRoundRepo; |
|
| 24 | + $this->roundRepo = $roundRepo; |
|
| 25 | + $this->match = $match; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public function all() |
|
| 29 | - { |
|
| 30 | - return $this->matchRoundRepo->all(); |
|
| 31 | - } |
|
| 32 | - /** |
|
| 33 | - * Method to get match data from input Match id |
|
| 34 | - * |
|
| 35 | - * @param mixed $matchdata |
|
| 36 | - * @return JSON object |
|
| 37 | - */ |
|
| 38 | - public function getByMatch($matchId) |
|
| 39 | - { |
|
| 40 | - return $this->matchRoundRepo->getByMatch($matchId); |
|
| 41 | - } |
|
| 28 | + public function all() |
|
| 29 | + { |
|
| 30 | + return $this->matchRoundRepo->all(); |
|
| 31 | + } |
|
| 32 | + /** |
|
| 33 | + * Method to get match data from input Match id |
|
| 34 | + * |
|
| 35 | + * @param mixed $matchdata |
|
| 36 | + * @return JSON object |
|
| 37 | + */ |
|
| 38 | + public function getByMatch($matchId) |
|
| 39 | + { |
|
| 40 | + return $this->matchRoundRepo->getByMatch($matchId); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function getByMatchAndGroup($matchdata) |
|
| 44 | - { |
|
| 45 | - //Retrieve players in group |
|
| 46 | - $players = $this->matchRoundRepo->matchGroup($matchdata['match_id'], $matchdata['group']); |
|
| 47 | - return $players; |
|
| 48 | - } |
|
| 43 | + public function getByMatchAndGroup($matchdata) |
|
| 44 | + { |
|
| 45 | + //Retrieve players in group |
|
| 46 | + $players = $this->matchRoundRepo->matchGroup($matchdata['match_id'], $matchdata['group']); |
|
| 47 | + return $players; |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -7,8 +7,7 @@ |
||
| 7 | 7 | /** |
| 8 | 8 | * Our MatchService, containing all useful methods for business logic around Matches |
| 9 | 9 | */ |
| 10 | -class MatchRoundService |
|
| 11 | -{ |
|
| 10 | +class MatchRoundService { |
|
| 12 | 11 | // Containing our pokemonRepository to make all our database calls to |
| 13 | 12 | protected $matchRepo; |
| 14 | 13 | |
@@ -21,7 +21,6 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * Loads our $matchRepo |
| 23 | 23 | * |
| 24 | - * @param MatchRepository $matchRepo |
|
| 25 | 24 | * @return MatchService |
| 26 | 25 | */ |
| 27 | 26 | public function __construct() |
@@ -7,8 +7,6 @@ |
||
| 7 | 7 | use \Netwinner; |
| 8 | 8 | use \Skin; |
| 9 | 9 | |
| 10 | -use Illuminate\Events\Dispatcher; |
|
| 11 | - |
|
| 12 | 10 | /** |
| 13 | 11 | * MoneyService, containing all useful methods for business logic for money relating to a match |
| 14 | 12 | */ |
@@ -15,28 +15,28 @@ |
||
| 15 | 15 | class MoneyService |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - // Containing our matchRepository to make all our database calls |
|
| 19 | - protected $matchRepo; |
|
| 18 | + // Containing our matchRepository to make all our database calls |
|
| 19 | + protected $matchRepo; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Loads our $matchRepo |
|
| 23 | - * |
|
| 24 | - * @param MatchRepository $matchRepo |
|
| 25 | - * @return MatchService |
|
| 26 | - */ |
|
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 21 | + /** |
|
| 22 | + * Loads our $matchRepo |
|
| 23 | + * |
|
| 24 | + * @param MatchRepository $matchRepo |
|
| 25 | + * @return MatchService |
|
| 26 | + */ |
|
| 27 | + public function __construct() |
|
| 28 | + { |
|
| 29 | 29 | |
| 30 | - } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function totalMatchMoney($matchId) |
|
| 33 | - { |
|
| 34 | - //get player id and money for ctp |
|
| 35 | - $results['ctps'] = Ctp::with('player')->where('match_id', '=', $matchId)->get(); |
|
| 36 | - $results['skins'] = Skin::with('player', 'hole')->where('match_id', '=', $matchId)->get(); |
|
| 37 | - $results['netwinner'] = Netwinner::with('player')->where('match_id', '=', $matchId)->get(); |
|
| 38 | - $results['grosswinner'] = Grosswinner::with('player')->where('match_id', '=', $matchId)->get(); |
|
| 39 | - $results['moneylist'] = Match::with('players')->where('id', '=', $matchId)->get(); |
|
| 32 | + public function totalMatchMoney($matchId) |
|
| 33 | + { |
|
| 34 | + //get player id and money for ctp |
|
| 35 | + $results['ctps'] = Ctp::with('player')->where('match_id', '=', $matchId)->get(); |
|
| 36 | + $results['skins'] = Skin::with('player', 'hole')->where('match_id', '=', $matchId)->get(); |
|
| 37 | + $results['netwinner'] = Netwinner::with('player')->where('match_id', '=', $matchId)->get(); |
|
| 38 | + $results['grosswinner'] = Grosswinner::with('player')->where('match_id', '=', $matchId)->get(); |
|
| 39 | + $results['moneylist'] = Match::with('players')->where('id', '=', $matchId)->get(); |
|
| 40 | 40 | return $results; |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | public function totalMatchMoney($matchId) |
| 33 | 33 | { |
| 34 | 34 | //get player id and money for ctp |
| 35 | - $results['ctps'] = Ctp::with('player')->where('match_id', '=', $matchId)->get(); |
|
| 35 | + $results['ctps'] = Ctp::with('player')->where('match_id', '=', $matchId)->get(); |
|
| 36 | 36 | $results['skins'] = Skin::with('player', 'hole')->where('match_id', '=', $matchId)->get(); |
| 37 | 37 | $results['netwinner'] = Netwinner::with('player')->where('match_id', '=', $matchId)->get(); |
| 38 | 38 | $results['grosswinner'] = Grosswinner::with('player')->where('match_id', '=', $matchId)->get(); |
@@ -12,8 +12,7 @@ |
||
| 12 | 12 | /** |
| 13 | 13 | * MoneyService, containing all useful methods for business logic for money relating to a match |
| 14 | 14 | */ |
| 15 | -class MoneyService |
|
| 16 | -{ |
|
| 15 | +class MoneyService { |
|
| 17 | 16 | |
| 18 | 17 | // Containing our matchRepository to make all our database calls |
| 19 | 18 | protected $matchRepo; |
@@ -3,17 +3,17 @@ |
||
| 3 | 3 | class Hole extends Eloquent |
| 4 | 4 | { |
| 5 | 5 | public function course() |
| 6 | - { |
|
| 7 | - return $this->belongsTo('Course'); |
|
| 8 | - } |
|
| 6 | + { |
|
| 7 | + return $this->belongsTo('Course'); |
|
| 8 | + } |
|
| 9 | 9 | |
| 10 | 10 | public function holescores() |
| 11 | - { |
|
| 12 | - return $this->hasMany('Holescore'); |
|
| 13 | - } |
|
| 11 | + { |
|
| 12 | + return $this->hasMany('Holescore'); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | public function courses() |
| 16 | - { |
|
| 17 | - return $this->hasManyThrough('Course','Holescore'); |
|
| 18 | - } |
|
| 16 | + { |
|
| 17 | + return $this->hasManyThrough('Course','Holescore'); |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -14,6 +14,6 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function courses() |
| 16 | 16 | { |
| 17 | - return $this->hasManyThrough('Course','Holescore'); |
|
| 17 | + return $this->hasManyThrough('Course', 'Holescore'); |
|
| 18 | 18 | } |
| 19 | 19 | } |
@@ -1,19 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class Hole extends Eloquent |
|
| 4 | -{ |
|
| 3 | +class Hole extends Eloquent { |
|
| 5 | 4 | public function course() |
| 6 | - { |
|
| 5 | + { |
|
| 7 | 6 | return $this->belongsTo('Course'); |
| 8 | 7 | } |
| 9 | 8 | |
| 10 | 9 | public function holescores() |
| 11 | - { |
|
| 10 | + { |
|
| 12 | 11 | return $this->hasMany('Holescore'); |
| 13 | 12 | } |
| 14 | 13 | |
| 15 | 14 | public function courses() |
| 16 | - { |
|
| 15 | + { |
|
| 17 | 16 | return $this->hasManyThrough('Course','Holescore'); |
| 18 | 17 | } |
| 19 | 18 | } |