@@ -6,16 +6,16 @@ |
||
| 6 | 6 | class ServicesServiceProvider extends ServiceProvider |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - public function register() |
|
| 10 | - { |
|
| 11 | - $this->app->bind('GolfLeague\PrizeMoney', function() |
|
| 12 | - { |
|
| 13 | - return new \GolfLeague\PrizeMoney; |
|
| 14 | - }); |
|
| 9 | + public function register() |
|
| 10 | + { |
|
| 11 | + $this->app->bind('GolfLeague\PrizeMoney', function() |
|
| 12 | + { |
|
| 13 | + return new \GolfLeague\PrizeMoney; |
|
| 14 | + }); |
|
| 15 | 15 | |
| 16 | - $this->app->bind('GolfLeague\Services\MoneyService', function() |
|
| 17 | - { |
|
| 18 | - return new \GolfLeague\Services\MoneyService; |
|
| 19 | - }); |
|
| 20 | - } |
|
| 16 | + $this->app->bind('GolfLeague\Services\MoneyService', function() |
|
| 17 | + { |
|
| 18 | + return new \GolfLeague\Services\MoneyService; |
|
| 19 | + }); |
|
| 20 | + } |
|
| 21 | 21 | } |
@@ -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 | } |
@@ -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 | } |
@@ -7,29 +7,29 @@ |
||
| 7 | 7 | class CarryOver |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - public function calculate() |
|
| 11 | - { |
|
| 12 | - $levels = Level::all(); |
|
| 13 | - $matches = Match::all(); |
|
| 14 | - $carryOverMoney = array(); |
|
| 15 | - foreach ($levels as $key => $level){ |
|
| 16 | - $carryOverMoney[$level->id] = 0; |
|
| 17 | - foreach($matches as $matchesKey => $match) { |
|
| 18 | - //check skins table for level and match |
|
| 19 | - $skins = Skin::where('match_id', '=', $match->id)->where('level_id', '=', $level->id)->get(); |
|
| 20 | - if($skins->count() === 0 ) { |
|
| 21 | - if ($level->id === 1){ |
|
| 22 | - $carryOverMoney[$level->id] += $match->skinsamoney; |
|
| 23 | - } |
|
| 24 | - else { |
|
| 25 | - $carryOverMoney[$level->id] += $match->skinsbmoney; |
|
| 26 | - } |
|
| 27 | - } |
|
| 28 | - else { |
|
| 29 | - $carryOverMoney[$level->id] = 0; //reset carryover money |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - }// End foreach |
|
| 33 | - return $carryOverMoney; |
|
| 34 | - } |
|
| 10 | + public function calculate() |
|
| 11 | + { |
|
| 12 | + $levels = Level::all(); |
|
| 13 | + $matches = Match::all(); |
|
| 14 | + $carryOverMoney = array(); |
|
| 15 | + foreach ($levels as $key => $level){ |
|
| 16 | + $carryOverMoney[$level->id] = 0; |
|
| 17 | + foreach($matches as $matchesKey => $match) { |
|
| 18 | + //check skins table for level and match |
|
| 19 | + $skins = Skin::where('match_id', '=', $match->id)->where('level_id', '=', $level->id)->get(); |
|
| 20 | + if($skins->count() === 0 ) { |
|
| 21 | + if ($level->id === 1){ |
|
| 22 | + $carryOverMoney[$level->id] += $match->skinsamoney; |
|
| 23 | + } |
|
| 24 | + else { |
|
| 25 | + $carryOverMoney[$level->id] += $match->skinsbmoney; |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | + else { |
|
| 29 | + $carryOverMoney[$level->id] = 0; //reset carryover money |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + }// End foreach |
|
| 33 | + return $carryOverMoney; |
|
| 34 | + } |
|
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -6,35 +6,35 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CalendarService |
| 8 | 8 | { |
| 9 | - // Containing our matchRepository to make all our database calls to |
|
| 10 | - protected $matchRepo; |
|
| 9 | + // Containing our matchRepository to make all our database calls to |
|
| 10 | + protected $matchRepo; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Loads our $matchRepo |
|
| 14 | - * |
|
| 15 | - * @param MatchRepository $matchRepo |
|
| 16 | - * @return CalendarService |
|
| 17 | - */ |
|
| 18 | - public function __construct(MatchRepository $matchRepo) |
|
| 19 | - { |
|
| 20 | - $this->matchRepo = $matchRepo; |
|
| 21 | - } |
|
| 12 | + /** |
|
| 13 | + * Loads our $matchRepo |
|
| 14 | + * |
|
| 15 | + * @param MatchRepository $matchRepo |
|
| 16 | + * @return CalendarService |
|
| 17 | + */ |
|
| 18 | + public function __construct(MatchRepository $matchRepo) |
|
| 19 | + { |
|
| 20 | + $this->matchRepo = $matchRepo; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function getByDate($startDate, $endDate) |
|
| 24 | - { |
|
| 25 | - $events = $this->matchRepo->getByDate($startDate, $endDate); |
|
| 26 | - //Decorate for javascript Calendar |
|
| 27 | - return $this->formatEvents($events); |
|
| 28 | - } |
|
| 23 | + public function getByDate($startDate, $endDate) |
|
| 24 | + { |
|
| 25 | + $events = $this->matchRepo->getByDate($startDate, $endDate); |
|
| 26 | + //Decorate for javascript Calendar |
|
| 27 | + return $this->formatEvents($events); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function formatEvents($events) |
|
| 31 | - { |
|
| 32 | - $events->toArray(); |
|
| 33 | - foreach($events as $event){ |
|
| 34 | - $event['title'] = 'Match ' . $event->course->name; |
|
| 35 | - $event['url'] = 'matches/' . $event->id . '/edit?group=1'; |
|
| 36 | - } |
|
| 37 | - return $events; |
|
| 38 | - } |
|
| 30 | + public function formatEvents($events) |
|
| 31 | + { |
|
| 32 | + $events->toArray(); |
|
| 33 | + foreach($events as $event){ |
|
| 34 | + $event['title'] = 'Match ' . $event->course->name; |
|
| 35 | + $event['url'] = 'matches/' . $event->id . '/edit?group=1'; |
|
| 36 | + } |
|
| 37 | + return $events; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -12,30 +12,30 @@ |
||
| 12 | 12 | class ScoreService |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - // Containing our matchRepository to make all our database calls |
|
| 16 | - protected $matchRepo; |
|
| 15 | + // Containing our matchRepository to make all our database calls |
|
| 16 | + protected $matchRepo; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Loads our $matchRepo |
|
| 20 | - * |
|
| 21 | - * @param MatchRepository $matchRepo |
|
| 22 | - * @return MatchService |
|
| 23 | - */ |
|
| 24 | - public function __construct(MatchRepository $matchRepo, |
|
| 25 | - HoleScoreRepo $holeScoreRepo, |
|
| 26 | - Player $player, |
|
| 27 | - Match $match, |
|
| 28 | - Dispatcher $events) |
|
| 29 | - { |
|
| 30 | - $this->matchRepo = $matchRepo; |
|
| 31 | - $this->holeScoreRepo = $holeScoreRepo; |
|
| 32 | - $this->player = $player; |
|
| 33 | - $this->match = $match; |
|
| 34 | - $this->events = $events; |
|
| 35 | - } |
|
| 18 | + /** |
|
| 19 | + * Loads our $matchRepo |
|
| 20 | + * |
|
| 21 | + * @param MatchRepository $matchRepo |
|
| 22 | + * @return MatchService |
|
| 23 | + */ |
|
| 24 | + public function __construct(MatchRepository $matchRepo, |
|
| 25 | + HoleScoreRepo $holeScoreRepo, |
|
| 26 | + Player $player, |
|
| 27 | + Match $match, |
|
| 28 | + Dispatcher $events) |
|
| 29 | + { |
|
| 30 | + $this->matchRepo = $matchRepo; |
|
| 31 | + $this->holeScoreRepo = $holeScoreRepo; |
|
| 32 | + $this->player = $player; |
|
| 33 | + $this->match = $match; |
|
| 34 | + $this->events = $events; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function update($id, $score) |
|
| 38 | - { |
|
| 39 | - $this->holeScoreRepo->update($id, $score); |
|
| 40 | - } |
|
| 37 | + public function update($id, $score) |
|
| 38 | + { |
|
| 39 | + $this->holeScoreRepo->update($id, $score); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -5,9 +5,9 @@ |
||
| 5 | 5 | class ScoreType |
| 6 | 6 | { |
| 7 | 7 | public function __construct() |
| 8 | - { |
|
| 8 | + { |
|
| 9 | 9 | |
| 10 | - } |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | 12 | public function calculate() |
| 13 | 13 | { |
@@ -3,27 +3,27 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | class PrizeMoney { |
| 5 | 5 | |
| 6 | - protected $lowScore = 7; |
|
| 7 | - protected $skins; |
|
| 8 | - protected $ctp = 5; |
|
| 9 | - protected $purse; |
|
| 6 | + protected $lowScore = 7; |
|
| 7 | + protected $skins; |
|
| 8 | + protected $ctp = 5; |
|
| 9 | + protected $purse; |
|
| 10 | 10 | protected $skinsPot; |
| 11 | 11 | |
| 12 | - public function setPurse($purse) |
|
| 13 | - { |
|
| 14 | - $this->purse = $this->asMoney($purse - ($this->ctp * 2)); |
|
| 15 | - } |
|
| 12 | + public function setPurse($purse) |
|
| 13 | + { |
|
| 14 | + $this->purse = $this->asMoney($purse - ($this->ctp * 2)); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function getlowScore() |
|
| 18 | - { |
|
| 17 | + public function getlowScore() |
|
| 18 | + { |
|
| 19 | 19 | return $this->asMoney($this->lowScore); |
| 20 | - } |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - public function getSkins() |
|
| 23 | - { |
|
| 24 | - $this->skins = .32 * $this->purse; |
|
| 25 | - return $this->asMoney($this->skins); |
|
| 26 | - } |
|
| 22 | + public function getSkins() |
|
| 23 | + { |
|
| 24 | + $this->skins = .32 * $this->purse; |
|
| 25 | + return $this->asMoney($this->skins); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | public function getSkinsPot($purse) |
| 29 | 29 | { |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | $groupPercentage = ($groupPlayers / $totalPlayers); |
| 38 | 38 | return ($groupPercentage * $this->skinsPot); |
| 39 | 39 | } |
| 40 | - public function getCtp() |
|
| 41 | - { |
|
| 42 | - return $this->asMoney($this->ctp); |
|
| 43 | - } |
|
| 40 | + public function getCtp() |
|
| 41 | + { |
|
| 42 | + return $this->asMoney($this->ctp); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | function asMoney($value) { |
| 46 | 46 | return number_format($value, 2); |
@@ -5,30 +5,30 @@ |
||
| 5 | 5 | class Games |
| 6 | 6 | { |
| 7 | 7 | public function __construct() |
| 8 | - { |
|
| 8 | + { |
|
| 9 | 9 | |
| 10 | - } |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | 12 | public function getGrossWinner() |
| 13 | 13 | { |
| 14 | 14 | return 'gross'; |
| 15 | 15 | //take an array of players and gross score |
| 16 | 16 | //find lowest and return |
| 17 | - //for each score in a given round determine +/- for each |
|
| 18 | - //sort and return |
|
| 17 | + //for each score in a given round determine +/- for each |
|
| 18 | + //sort and return |
|
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function getNetWinner() |
|
| 24 | - { |
|
| 25 | - //for each score in a given round determine +/- for each AFTER subtracting handicap |
|
| 23 | + public function getNetWinner() |
|
| 24 | + { |
|
| 25 | + //for each score in a given round determine +/- for each AFTER subtracting handicap |
|
| 26 | 26 | |
| 27 | - } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function currentParTotal($courseId, $holesPlayed) |
|
| 30 | - { |
|
| 31 | - //find par total for course given unmber of holes played |
|
| 29 | + public function currentParTotal($courseId, $holesPlayed) |
|
| 30 | + { |
|
| 31 | + //find par total for course given unmber of holes played |
|
| 32 | 32 | |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |