@@ -42,7 +42,6 @@ |
||
| 42 | 42 | /** |
| 43 | 43 | * Show the form for editing the specified resource. |
| 44 | 44 | * |
| 45 | - * @param int $id |
|
| 46 | 45 | * @return Response |
| 47 | 46 | */ |
| 48 | 47 | public function edit() |
@@ -2,96 +2,96 @@ |
||
| 2 | 2 | |
| 3 | 3 | class CoursesController extends \BaseController { |
| 4 | 4 | |
| 5 | - public function __construct(Course $course) |
|
| 6 | - { |
|
| 7 | - $this->course = $course; |
|
| 8 | - } |
|
| 5 | + public function __construct(Course $course) |
|
| 6 | + { |
|
| 7 | + $this->course = $course; |
|
| 8 | + } |
|
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * Show the form for creating a new resource. |
|
| 12 | - * |
|
| 13 | - * @return Response |
|
| 14 | - */ |
|
| 15 | - public function index() |
|
| 16 | - { |
|
| 17 | - $data = $this->course->all(); |
|
| 18 | - return $data; |
|
| 19 | - } |
|
| 10 | + /** |
|
| 11 | + * Show the form for creating a new resource. |
|
| 12 | + * |
|
| 13 | + * @return Response |
|
| 14 | + */ |
|
| 15 | + public function index() |
|
| 16 | + { |
|
| 17 | + $data = $this->course->all(); |
|
| 18 | + return $data; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Store a newly created resource in storage. |
|
| 23 | - * |
|
| 24 | - * @return Response |
|
| 25 | - */ |
|
| 26 | - public function store() |
|
| 27 | - { |
|
| 28 | - // |
|
| 29 | - } |
|
| 21 | + /** |
|
| 22 | + * Store a newly created resource in storage. |
|
| 23 | + * |
|
| 24 | + * @return Response |
|
| 25 | + */ |
|
| 26 | + public function store() |
|
| 27 | + { |
|
| 28 | + // |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Display the specified resource. |
|
| 33 | - * |
|
| 34 | - * @param int $id |
|
| 35 | - * @return Response |
|
| 36 | - */ |
|
| 37 | - public function show($id) |
|
| 38 | - { |
|
| 39 | - return Course::find($id)->get(); |
|
| 40 | - } |
|
| 31 | + /** |
|
| 32 | + * Display the specified resource. |
|
| 33 | + * |
|
| 34 | + * @param int $id |
|
| 35 | + * @return Response |
|
| 36 | + */ |
|
| 37 | + public function show($id) |
|
| 38 | + { |
|
| 39 | + return Course::find($id)->get(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Show the form for editing the specified resource. |
|
| 44 | - * |
|
| 45 | - * @param int $id |
|
| 46 | - * @return Response |
|
| 47 | - */ |
|
| 48 | - public function edit() |
|
| 49 | - { |
|
| 42 | + /** |
|
| 43 | + * Show the form for editing the specified resource. |
|
| 44 | + * |
|
| 45 | + * @param int $id |
|
| 46 | + * @return Response |
|
| 47 | + */ |
|
| 48 | + public function edit() |
|
| 49 | + { |
|
| 50 | 50 | $operation = Input::get('oper'); |
| 51 | - switch ($operation) { |
|
| 52 | - case "add": |
|
| 53 | - $this->course->name = Input::get('name'); |
|
| 51 | + switch ($operation) { |
|
| 52 | + case "add": |
|
| 53 | + $this->course->name = Input::get('name'); |
|
| 54 | 54 | $this->course->par = Input::get('par'); |
| 55 | 55 | $this->course->rating = Input::get('rating'); |
| 56 | 56 | $this->course->slope = Input::get('slope'); |
| 57 | - $this->course->save(); |
|
| 58 | - break; |
|
| 59 | - case "edit": |
|
| 60 | - $id = Input::get('id'); |
|
| 61 | - $this->course = $this->course->find($id); |
|
| 62 | - $this->course->name = Input::get('name'); |
|
| 57 | + $this->course->save(); |
|
| 58 | + break; |
|
| 59 | + case "edit": |
|
| 60 | + $id = Input::get('id'); |
|
| 61 | + $this->course = $this->course->find($id); |
|
| 62 | + $this->course->name = Input::get('name'); |
|
| 63 | 63 | $this->course->par = Input::get('par'); |
| 64 | 64 | $this->course->rating = Input::get('rating'); |
| 65 | 65 | $this->course->slope = Input::get('slope'); |
| 66 | - $this->course->save(); |
|
| 67 | - break; |
|
| 68 | - case "del": |
|
| 69 | - $id = Input::get('id'); |
|
| 70 | - $this->course = $this->course->destroy($id); |
|
| 71 | - break; |
|
| 72 | - } |
|
| 73 | - } |
|
| 66 | + $this->course->save(); |
|
| 67 | + break; |
|
| 68 | + case "del": |
|
| 69 | + $id = Input::get('id'); |
|
| 70 | + $this->course = $this->course->destroy($id); |
|
| 71 | + break; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Update the specified resource in storage. |
|
| 77 | - * |
|
| 78 | - * @param int $id |
|
| 79 | - * @return Response |
|
| 80 | - */ |
|
| 81 | - public function update($id) |
|
| 82 | - { |
|
| 83 | - // |
|
| 84 | - } |
|
| 75 | + /** |
|
| 76 | + * Update the specified resource in storage. |
|
| 77 | + * |
|
| 78 | + * @param int $id |
|
| 79 | + * @return Response |
|
| 80 | + */ |
|
| 81 | + public function update($id) |
|
| 82 | + { |
|
| 83 | + // |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Remove the specified resource from storage. |
|
| 88 | - * |
|
| 89 | - * @param int $id |
|
| 90 | - * @return Response |
|
| 91 | - */ |
|
| 92 | - public function destroy($id) |
|
| 93 | - { |
|
| 94 | - // |
|
| 95 | - } |
|
| 86 | + /** |
|
| 87 | + * Remove the specified resource from storage. |
|
| 88 | + * |
|
| 89 | + * @param int $id |
|
| 90 | + * @return Response |
|
| 91 | + */ |
|
| 92 | + public function destroy($id) |
|
| 93 | + { |
|
| 94 | + // |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | \ No newline at end of file |
@@ -49,26 +49,26 @@ |
||
| 49 | 49 | { |
| 50 | 50 | $operation = Input::get('oper'); |
| 51 | 51 | switch ($operation) { |
| 52 | - case "add": |
|
| 53 | - $this->course->name = Input::get('name'); |
|
| 54 | - $this->course->par = Input::get('par'); |
|
| 55 | - $this->course->rating = Input::get('rating'); |
|
| 56 | - $this->course->slope = Input::get('slope'); |
|
| 57 | - $this->course->save(); |
|
| 58 | - break; |
|
| 59 | - case "edit": |
|
| 60 | - $id = Input::get('id'); |
|
| 61 | - $this->course = $this->course->find($id); |
|
| 62 | - $this->course->name = Input::get('name'); |
|
| 63 | - $this->course->par = Input::get('par'); |
|
| 64 | - $this->course->rating = Input::get('rating'); |
|
| 65 | - $this->course->slope = Input::get('slope'); |
|
| 66 | - $this->course->save(); |
|
| 67 | - break; |
|
| 68 | - case "del": |
|
| 69 | - $id = Input::get('id'); |
|
| 70 | - $this->course = $this->course->destroy($id); |
|
| 71 | - break; |
|
| 52 | + case "add": |
|
| 53 | + $this->course->name = Input::get('name'); |
|
| 54 | + $this->course->par = Input::get('par'); |
|
| 55 | + $this->course->rating = Input::get('rating'); |
|
| 56 | + $this->course->slope = Input::get('slope'); |
|
| 57 | + $this->course->save(); |
|
| 58 | + break; |
|
| 59 | + case "edit": |
|
| 60 | + $id = Input::get('id'); |
|
| 61 | + $this->course = $this->course->find($id); |
|
| 62 | + $this->course->name = Input::get('name'); |
|
| 63 | + $this->course->par = Input::get('par'); |
|
| 64 | + $this->course->rating = Input::get('rating'); |
|
| 65 | + $this->course->slope = Input::get('slope'); |
|
| 66 | + $this->course->save(); |
|
| 67 | + break; |
|
| 68 | + case "del": |
|
| 69 | + $id = Input::get('id'); |
|
| 70 | + $this->course = $this->course->destroy($id); |
|
| 71 | + break; |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -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 | /** |
@@ -3,7 +3,7 @@ |
||
| 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 | } |
@@ -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 |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * Create a new instance of the MatchHandler |
| 23 | 23 | * |
| 24 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 24 | + * @param RoundRepository $roundRepo |
|
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | 27 | public function __construct(RoundRepository $roundRepo) |
@@ -18,103 +18,103 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class FinalizeHandler |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Create a new instance of the MatchHandler |
|
| 23 | - * |
|
| 24 | - * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 25 | - * @return void |
|
| 26 | - */ |
|
| 27 | - public function __construct(RoundRepository $roundRepo) |
|
| 28 | - { |
|
| 29 | - $this->roundRepo= $roundRepo; |
|
| 30 | - } // End of __construct |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Create an initial round for each player after a new match is created |
|
| 34 | - * |
|
| 35 | - * @param Match $match |
|
| 36 | - * @return void |
|
| 37 | - */ |
|
| 38 | - public function handle($match) |
|
| 39 | - { |
|
| 40 | - // For the match get ctps, netwinner, grosswinner, and skins |
|
| 41 | - // calculate winnings store in the pivot table |
|
| 42 | - // match_player for the given player |
|
| 43 | - |
|
| 44 | - $winningPlayers = array(); |
|
| 45 | - $i = 1; |
|
| 46 | - |
|
| 47 | - $ctpWinners = Ctp::where('match_id', '=', $match->id)->get(); |
|
| 48 | - $winningPlayers = $this->gameWinner($ctpWinners, $winningPlayers); |
|
| 49 | - |
|
| 50 | - $netWinners = Netwinner::where('match_id', '=', $match->id)->get(); |
|
| 51 | - $winningPlayers = $this->gameWinner($netWinners, $winningPlayers); |
|
| 52 | - |
|
| 53 | - $grossWinners = Grosswinner::where('match_id', '=', $match->id)->get(); |
|
| 54 | - $winningPlayers = $this->gameWinner($grossWinners, $winningPlayers); |
|
| 55 | - |
|
| 56 | - $skinWinners = Skin::where('match_id', '=', $match->id)->get(); |
|
| 57 | - $winningPlayers = $this->gameWinner($skinWinners, $winningPlayers); |
|
| 58 | - |
|
| 59 | - //Consolidate money for any multiple instances of a player |
|
| 60 | - foreach ($winningPlayers as $key => $winningPlayer){ |
|
| 61 | - array_search($winningPlayer['player_id'], $winningPlayers); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - // update pivot table with winners data |
|
| 65 | - foreach ($winningPlayers as $key => $player){ |
|
| 66 | - $currentPlayer = Player::find($player['player_id']); |
|
| 67 | - $attributes = array( |
|
| 68 | - "winnings" => $player['money'] |
|
| 69 | - ); |
|
| 70 | - $currentPlayer->matches()->updateExistingPivot($match->id, $attributes); //save match_player pivot data |
|
| 71 | - }// End foreach |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Register the listeners for the subscriber. |
|
| 78 | - * |
|
| 79 | - * @param Illuminate\Events\Dispatcher $events |
|
| 80 | - * @return array |
|
| 81 | - */ |
|
| 82 | - public function subscribe($events) |
|
| 83 | - { |
|
| 84 | - $events->listen('match.finalize', 'GolfLeague\Handlers\FinalizeHandler'); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /* |
|
| 21 | + /** |
|
| 22 | + * Create a new instance of the MatchHandler |
|
| 23 | + * |
|
| 24 | + * @param GolfLeague\Storage\Round\RoundRepository $roundRepo |
|
| 25 | + * @return void |
|
| 26 | + */ |
|
| 27 | + public function __construct(RoundRepository $roundRepo) |
|
| 28 | + { |
|
| 29 | + $this->roundRepo= $roundRepo; |
|
| 30 | + } // End of __construct |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Create an initial round for each player after a new match is created |
|
| 34 | + * |
|
| 35 | + * @param Match $match |
|
| 36 | + * @return void |
|
| 37 | + */ |
|
| 38 | + public function handle($match) |
|
| 39 | + { |
|
| 40 | + // For the match get ctps, netwinner, grosswinner, and skins |
|
| 41 | + // calculate winnings store in the pivot table |
|
| 42 | + // match_player for the given player |
|
| 43 | + |
|
| 44 | + $winningPlayers = array(); |
|
| 45 | + $i = 1; |
|
| 46 | + |
|
| 47 | + $ctpWinners = Ctp::where('match_id', '=', $match->id)->get(); |
|
| 48 | + $winningPlayers = $this->gameWinner($ctpWinners, $winningPlayers); |
|
| 49 | + |
|
| 50 | + $netWinners = Netwinner::where('match_id', '=', $match->id)->get(); |
|
| 51 | + $winningPlayers = $this->gameWinner($netWinners, $winningPlayers); |
|
| 52 | + |
|
| 53 | + $grossWinners = Grosswinner::where('match_id', '=', $match->id)->get(); |
|
| 54 | + $winningPlayers = $this->gameWinner($grossWinners, $winningPlayers); |
|
| 55 | + |
|
| 56 | + $skinWinners = Skin::where('match_id', '=', $match->id)->get(); |
|
| 57 | + $winningPlayers = $this->gameWinner($skinWinners, $winningPlayers); |
|
| 58 | + |
|
| 59 | + //Consolidate money for any multiple instances of a player |
|
| 60 | + foreach ($winningPlayers as $key => $winningPlayer){ |
|
| 61 | + array_search($winningPlayer['player_id'], $winningPlayers); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + // update pivot table with winners data |
|
| 65 | + foreach ($winningPlayers as $key => $player){ |
|
| 66 | + $currentPlayer = Player::find($player['player_id']); |
|
| 67 | + $attributes = array( |
|
| 68 | + "winnings" => $player['money'] |
|
| 69 | + ); |
|
| 70 | + $currentPlayer->matches()->updateExistingPivot($match->id, $attributes); //save match_player pivot data |
|
| 71 | + }// End foreach |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Register the listeners for the subscriber. |
|
| 78 | + * |
|
| 79 | + * @param Illuminate\Events\Dispatcher $events |
|
| 80 | + * @return array |
|
| 81 | + */ |
|
| 82 | + public function subscribe($events) |
|
| 83 | + { |
|
| 84 | + $events->listen('match.finalize', 'GolfLeague\Handlers\FinalizeHandler'); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /* |
|
| 88 | 88 | * Takes array of |
| 89 | 89 | * @param array $gameWinner |
| 90 | 90 | * @param array $winningPlayers |
| 91 | 91 | */ |
| 92 | - public function gameWinner($gameWinners, $winningPlayers) |
|
| 93 | - { |
|
| 94 | - foreach($gameWinners as $key => $gameWinner){ |
|
| 95 | - $playerExists = $this->recursive_array_search($gameWinner->player_id, $winningPlayers); |
|
| 96 | - //if player is already there add money here to other money |
|
| 97 | - if($playerExists){ |
|
| 98 | - $winningPlayers[$i]['player_id'] = $gameWinner->player_id; |
|
| 99 | - $winningPlayers[$i]['money'] = ($gameWinner->money + $winningPlayers[$playerExists]['money']); |
|
| 100 | - unset($winningPlayers[$playerExists]); |
|
| 101 | - } |
|
| 102 | - else { |
|
| 103 | - $winningPlayers[$i]['player_id'] = $gameWinner->player_id; |
|
| 104 | - $winningPlayers[$i]['money'] = $gameWinner->money; |
|
| 105 | - } |
|
| 106 | - $i++; |
|
| 107 | - } |
|
| 108 | - return $winningPlayers; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - public function recursive_array_search($needle,$haystack) { |
|
| 112 | - foreach($haystack as $key=>$value) { |
|
| 113 | - $current_key=$key; |
|
| 114 | - if($needle===$value || (is_array($value) && $this->recursive_array_search($needle,$value) !== false)) { |
|
| 115 | - return $current_key; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - return false; |
|
| 119 | - } |
|
| 92 | + public function gameWinner($gameWinners, $winningPlayers) |
|
| 93 | + { |
|
| 94 | + foreach($gameWinners as $key => $gameWinner){ |
|
| 95 | + $playerExists = $this->recursive_array_search($gameWinner->player_id, $winningPlayers); |
|
| 96 | + //if player is already there add money here to other money |
|
| 97 | + if($playerExists){ |
|
| 98 | + $winningPlayers[$i]['player_id'] = $gameWinner->player_id; |
|
| 99 | + $winningPlayers[$i]['money'] = ($gameWinner->money + $winningPlayers[$playerExists]['money']); |
|
| 100 | + unset($winningPlayers[$playerExists]); |
|
| 101 | + } |
|
| 102 | + else { |
|
| 103 | + $winningPlayers[$i]['player_id'] = $gameWinner->player_id; |
|
| 104 | + $winningPlayers[$i]['money'] = $gameWinner->money; |
|
| 105 | + } |
|
| 106 | + $i++; |
|
| 107 | + } |
|
| 108 | + return $winningPlayers; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public function recursive_array_search($needle,$haystack) { |
|
| 112 | + foreach($haystack as $key=>$value) { |
|
| 113 | + $current_key=$key; |
|
| 114 | + if($needle===$value || (is_array($value) && $this->recursive_array_search($needle,$value) !== false)) { |
|
| 115 | + return $current_key; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + return false; |
|
| 119 | + } |
|
| 120 | 120 | } |
@@ -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 | /** |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | $winningPlayers = $this->gameWinner($skinWinners, $winningPlayers); |
| 58 | 58 | |
| 59 | 59 | //Consolidate money for any multiple instances of a player |
| 60 | - foreach ($winningPlayers as $key => $winningPlayer){ |
|
| 60 | + foreach ($winningPlayers as $key => $winningPlayer) { |
|
| 61 | 61 | array_search($winningPlayer['player_id'], $winningPlayers); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // update pivot table with winners data |
| 65 | - foreach ($winningPlayers as $key => $player){ |
|
| 65 | + foreach ($winningPlayers as $key => $player) { |
|
| 66 | 66 | $currentPlayer = Player::find($player['player_id']); |
| 67 | 67 | $attributes = array( |
| 68 | 68 | "winnings" => $player['money'] |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function gameWinner($gameWinners, $winningPlayers) |
| 93 | 93 | { |
| 94 | - foreach($gameWinners as $key => $gameWinner){ |
|
| 94 | + foreach ($gameWinners as $key => $gameWinner) { |
|
| 95 | 95 | $playerExists = $this->recursive_array_search($gameWinner->player_id, $winningPlayers); |
| 96 | 96 | //if player is already there add money here to other money |
| 97 | - if($playerExists){ |
|
| 97 | + if ($playerExists) { |
|
| 98 | 98 | $winningPlayers[$i]['player_id'] = $gameWinner->player_id; |
| 99 | 99 | $winningPlayers[$i]['money'] = ($gameWinner->money + $winningPlayers[$playerExists]['money']); |
| 100 | 100 | unset($winningPlayers[$playerExists]); |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | return $winningPlayers; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - public function recursive_array_search($needle,$haystack) { |
|
| 112 | - foreach($haystack as $key=>$value) { |
|
| 113 | - $current_key=$key; |
|
| 114 | - if($needle===$value || (is_array($value) && $this->recursive_array_search($needle,$value) !== false)) { |
|
| 111 | + public function recursive_array_search($needle, $haystack) { |
|
| 112 | + foreach ($haystack as $key=>$value) { |
|
| 113 | + $current_key = $key; |
|
| 114 | + if ($needle === $value || (is_array($value) && $this->recursive_array_search($needle, $value) !== false)) { |
|
| 115 | 115 | return $current_key; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -16,8 +16,7 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @author Michael Schmidt |
| 18 | 18 | */ |
| 19 | -class FinalizeHandler |
|
| 20 | -{ |
|
| 19 | +class FinalizeHandler { |
|
| 21 | 20 | /** |
| 22 | 21 | * Create a new instance of the MatchHandler |
| 23 | 22 | * |
@@ -57,12 +56,12 @@ discard block |
||
| 57 | 56 | $winningPlayers = $this->gameWinner($skinWinners, $winningPlayers); |
| 58 | 57 | |
| 59 | 58 | //Consolidate money for any multiple instances of a player |
| 60 | - foreach ($winningPlayers as $key => $winningPlayer){ |
|
| 59 | + foreach ($winningPlayers as $key => $winningPlayer) { |
|
| 61 | 60 | array_search($winningPlayer['player_id'], $winningPlayers); |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 | // update pivot table with winners data |
| 65 | - foreach ($winningPlayers as $key => $player){ |
|
| 64 | + foreach ($winningPlayers as $key => $player) { |
|
| 66 | 65 | $currentPlayer = Player::find($player['player_id']); |
| 67 | 66 | $attributes = array( |
| 68 | 67 | "winnings" => $player['money'] |
@@ -91,15 +90,14 @@ discard block |
||
| 91 | 90 | */ |
| 92 | 91 | public function gameWinner($gameWinners, $winningPlayers) |
| 93 | 92 | { |
| 94 | - foreach($gameWinners as $key => $gameWinner){ |
|
| 93 | + foreach($gameWinners as $key => $gameWinner) { |
|
| 95 | 94 | $playerExists = $this->recursive_array_search($gameWinner->player_id, $winningPlayers); |
| 96 | 95 | //if player is already there add money here to other money |
| 97 | - if($playerExists){ |
|
| 96 | + if($playerExists) { |
|
| 98 | 97 | $winningPlayers[$i]['player_id'] = $gameWinner->player_id; |
| 99 | 98 | $winningPlayers[$i]['money'] = ($gameWinner->money + $winningPlayers[$playerExists]['money']); |
| 100 | 99 | unset($winningPlayers[$playerExists]); |
| 101 | - } |
|
| 102 | - else { |
|
| 100 | + } else { |
|
| 103 | 101 | $winningPlayers[$i]['player_id'] = $gameWinner->player_id; |
| 104 | 102 | $winningPlayers[$i]['money'] = $gameWinner->money; |
| 105 | 103 | } |
@@ -108,7 +106,8 @@ discard block |
||
| 108 | 106 | return $winningPlayers; |
| 109 | 107 | } |
| 110 | 108 | |
| 111 | - public function recursive_array_search($needle,$haystack) { |
|
| 109 | + public function recursive_array_search($needle,$haystack) |
|
| 110 | + { |
|
| 112 | 111 | foreach($haystack as $key=>$value) { |
| 113 | 112 | $current_key=$key; |
| 114 | 113 | if($needle===$value || (is_array($value) && $this->recursive_array_search($needle,$value) !== false)) { |
@@ -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 | |