@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Created by PhpStorm. |
|
| 4 | - * User: michaelschmidt |
|
| 5 | - * Date: 4/2/16 |
|
| 6 | - * Time: 4:25 PM |
|
| 7 | - */ |
|
| 3 | + * Created by PhpStorm. |
|
| 4 | + * User: michaelschmidt |
|
| 5 | + * Date: 4/2/16 |
|
| 6 | + * Time: 4:25 PM |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | use Zizaco\Confide\UserValidator as ConfideUserValidator; |
| 10 | 10 | use Zizaco\Confide\UserValidatorInterface; |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | class UserValidator extends ConfideUserValidator implements UserValidatorInterface |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - public $rules = [ |
|
| 16 | - 'create' => [ |
|
| 17 | - 'email' => 'required|email', |
|
| 18 | - 'password' => 'required|min:4', |
|
| 19 | - ], |
|
| 20 | - 'update' => [ |
|
| 21 | - 'email' => 'required|email', |
|
| 22 | - 'password' => 'required|min:4', |
|
| 23 | - ] |
|
| 24 | - ]; |
|
| 15 | + public $rules = [ |
|
| 16 | + 'create' => [ |
|
| 17 | + 'email' => 'required|email', |
|
| 18 | + 'password' => 'required|min:4', |
|
| 19 | + ], |
|
| 20 | + 'update' => [ |
|
| 21 | + 'email' => 'required|email', |
|
| 22 | + 'password' => 'required|min:4', |
|
| 23 | + ] |
|
| 24 | + ]; |
|
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -9,8 +9,7 @@ |
||
| 9 | 9 | use Zizaco\Confide\UserValidator as ConfideUserValidator; |
| 10 | 10 | use Zizaco\Confide\UserValidatorInterface; |
| 11 | 11 | |
| 12 | -class UserValidator extends ConfideUserValidator implements UserValidatorInterface |
|
| 13 | -{ |
|
| 12 | +class UserValidator extends ConfideUserValidator implements UserValidatorInterface { |
|
| 14 | 13 | |
| 15 | 14 | public $rules = [ |
| 16 | 15 | 'create' => [ |
@@ -5,44 +5,44 @@ discard block |
||
| 5 | 5 | protected $table = 'matches'; |
| 6 | 6 | |
| 7 | 7 | public function setDateAttribute($date) |
| 8 | - { |
|
| 8 | + { |
|
| 9 | 9 | $this->attributes['date'] = date('Y-m-d', strtotime(str_replace('-', '/', $date))); |
| 10 | - } |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | 12 | public function course() |
| 13 | - { |
|
| 14 | - return $this->belongsTo('Course'); |
|
| 15 | - } |
|
| 13 | + { |
|
| 14 | + return $this->belongsTo('Course'); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | 17 | public function season() |
| 18 | - { |
|
| 19 | - return $this->belongsTo('Season'); |
|
| 20 | - } |
|
| 18 | + { |
|
| 19 | + return $this->belongsTo('Season'); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | 22 | public function winners() |
| 23 | - { |
|
| 24 | - return $this->hasMany('Winner'); |
|
| 25 | - } |
|
| 23 | + { |
|
| 24 | + return $this->hasMany('Winner'); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | public function money() |
| 28 | - { |
|
| 29 | - return $this->hasMany('Money'); |
|
| 30 | - } |
|
| 28 | + { |
|
| 29 | + return $this->hasMany('Money'); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | public function skins() |
| 33 | - { |
|
| 34 | - return $this->hasMany('Skin'); |
|
| 35 | - } |
|
| 33 | + { |
|
| 34 | + return $this->hasMany('Skin'); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | public function players() |
| 38 | - { |
|
| 39 | - return $this->belongsToMany('Player')->withPivot('level_id', 'group', 'handicap', 'winnings')->orderBy('pivot_winnings', 'desc')->withTimestamps(); |
|
| 40 | - } |
|
| 38 | + { |
|
| 39 | + return $this->belongsToMany('Player')->withPivot('level_id', 'group', 'handicap', 'winnings')->orderBy('pivot_winnings', 'desc')->withTimestamps(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function playersEdit() |
|
| 43 | - { |
|
| 44 | - return $this->belongsToMany('Player')->withPivot('level_id', 'group', 'handicap', 'winnings')->orderBy('pivot_group', 'asc')->withTimestamps(); |
|
| 45 | - } |
|
| 42 | + public function playersEdit() |
|
| 43 | + { |
|
| 44 | + return $this->belongsToMany('Player')->withPivot('level_id', 'group', 'handicap', 'winnings')->orderBy('pivot_group', 'asc')->withTimestamps(); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | public function rounds() |
| 48 | 48 | { |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | public function holes() |
| 53 | 53 | { |
| 54 | - return $this->hasManyThrough('Hole', 'Course'); |
|
| 55 | - } |
|
| 54 | + return $this->hasManyThrough('Hole', 'Course'); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | public function getAllMatches() |
| 58 | 58 | { |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | * Multideminsional Array of Hole Numbers and scores * |
| 15 | 15 | **/ |
| 16 | 16 | public function __construct(Match $match, Player $player) |
| 17 | - { |
|
| 18 | - $this->match = $match; |
|
| 17 | + { |
|
| 18 | + $this->match = $match; |
|
| 19 | 19 | $this->player = $player; |
| 20 | - } |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - public function all() |
|
| 23 | - { |
|
| 22 | + public function all() |
|
| 23 | + { |
|
| 24 | 24 | return Match::orderBy('date', 'DESC')->get(); |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | public function get($matchid) |
| 28 | 28 | { |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | return array_unique($years); |
| 59 | 59 | } |
| 60 | - //Find Scores by Player Id |
|
| 61 | - public function find($playerId) |
|
| 62 | - { |
|
| 63 | - //return Round::with('player', 'holescores')->where('player_id', '=', $playerId)->get(); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function create($matchdata) |
|
| 67 | - { |
|
| 60 | + //Find Scores by Player Id |
|
| 61 | + public function find($playerId) |
|
| 62 | + { |
|
| 63 | + //return Round::with('player', 'holescores')->where('player_id', '=', $playerId)->get(); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function create($matchdata) |
|
| 67 | + { |
|
| 68 | 68 | //enter match data to Matches table |
| 69 | 69 | $this->match->date = $matchdata['date']; |
| 70 | 70 | $this->match->course_id = $matchdata['course']; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $currentPlayer->matches()->save($this->match, $attributes); //save match_player pivot data |
| 88 | 88 | }// End foreach |
| 89 | 89 | return $this->match->id; |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | public function update($matchdata) |
| 93 | 93 | { |
@@ -10,89 +10,89 @@ |
||
| 10 | 10 | |
| 11 | 11 | class PlayerStatisticsEloquent implements PlayerStatistics |
| 12 | 12 | { |
| 13 | - private $date1 = '-01-01'; |
|
| 14 | - private $date2 = '-12-31'; |
|
| 13 | + private $date1 = '-01-01'; |
|
| 14 | + private $date2 = '-12-31'; |
|
| 15 | 15 | |
| 16 | - public function matchesHandicap($playerId){} |
|
| 17 | - public function scoringAverage($playerId) |
|
| 18 | - { |
|
| 19 | - $today = Carbon::now()->toDateString(); |
|
| 20 | - $rounds = Round::where('player_id', '=', $playerId) |
|
| 21 | - ->where('date', '<', $today) |
|
| 22 | - ->get(); |
|
| 23 | - $scores = $rounds->map(function($round) |
|
| 24 | - { |
|
| 25 | - return $round->score; |
|
| 26 | - }); |
|
| 27 | - if($rounds->count() > 0) { |
|
| 28 | - return round(array_sum($scores->toArray())/($rounds->count()), 2); |
|
| 29 | - } else { |
|
| 30 | - return $rounds; |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - public function scoringAverageByYear($playerId, $year) |
|
| 34 | - { |
|
| 35 | - $rounds = Round::where('player_id', '=', $playerId) |
|
| 36 | - ->where('date', '>=', $year . $this->date1) |
|
| 37 | - ->where('date', '<=', $year . $this->date2) |
|
| 38 | - ->get(); |
|
| 39 | - $scores = $rounds->map(function($round) |
|
| 40 | - { |
|
| 41 | - return $round->score; |
|
| 42 | - }); |
|
| 43 | - if($rounds->count() > 0) { |
|
| 44 | - return round(array_sum($scores->toArray())/($rounds->count()), 2); |
|
| 45 | - } else { |
|
| 46 | - return $rounds; |
|
| 47 | - } |
|
| 16 | + public function matchesHandicap($playerId){} |
|
| 17 | + public function scoringAverage($playerId) |
|
| 18 | + { |
|
| 19 | + $today = Carbon::now()->toDateString(); |
|
| 20 | + $rounds = Round::where('player_id', '=', $playerId) |
|
| 21 | + ->where('date', '<', $today) |
|
| 22 | + ->get(); |
|
| 23 | + $scores = $rounds->map(function($round) |
|
| 24 | + { |
|
| 25 | + return $round->score; |
|
| 26 | + }); |
|
| 27 | + if($rounds->count() > 0) { |
|
| 28 | + return round(array_sum($scores->toArray())/($rounds->count()), 2); |
|
| 29 | + } else { |
|
| 30 | + return $rounds; |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + public function scoringAverageByYear($playerId, $year) |
|
| 34 | + { |
|
| 35 | + $rounds = Round::where('player_id', '=', $playerId) |
|
| 36 | + ->where('date', '>=', $year . $this->date1) |
|
| 37 | + ->where('date', '<=', $year . $this->date2) |
|
| 38 | + ->get(); |
|
| 39 | + $scores = $rounds->map(function($round) |
|
| 40 | + { |
|
| 41 | + return $round->score; |
|
| 42 | + }); |
|
| 43 | + if($rounds->count() > 0) { |
|
| 44 | + return round(array_sum($scores->toArray())/($rounds->count()), 2); |
|
| 45 | + } else { |
|
| 46 | + return $rounds; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - } |
|
| 51 | - public function scoringAverageMatchesByYear($year){} |
|
| 52 | - public function handicapRounds($playerId){} |
|
| 50 | + } |
|
| 51 | + public function scoringAverageMatchesByYear($year){} |
|
| 52 | + public function handicapRounds($playerId){} |
|
| 53 | 53 | |
| 54 | - public function scoringAverageCourse($course){} |
|
| 55 | - public function scoringAverageCourseByYear($course, $year){} |
|
| 56 | - public function scoringAverageCourseMatchesByYear($course, $year){} |
|
| 54 | + public function scoringAverageCourse($course){} |
|
| 55 | + public function scoringAverageCourseByYear($course, $year){} |
|
| 56 | + public function scoringAverageCourseMatchesByYear($course, $year){} |
|
| 57 | 57 | |
| 58 | - public function totalEagles(){} |
|
| 59 | - public function eaglesByYear($year){} |
|
| 60 | - public function eaglesMatchesByYear($year){} |
|
| 58 | + public function totalEagles(){} |
|
| 59 | + public function eaglesByYear($year){} |
|
| 60 | + public function eaglesMatchesByYear($year){} |
|
| 61 | 61 | |
| 62 | - public function totalBirdies($playerId){} |
|
| 63 | - public function birdiesByYear($playerId, $year) |
|
| 64 | - { |
|
| 65 | - $year = $year . '-01-01'; |
|
| 66 | - $holescores = Holescore::with('round.player','hole') |
|
| 67 | - ->where('created_at', '>', $year) |
|
| 68 | - ->get(); |
|
| 69 | - $allBirdies = array(); |
|
| 70 | - foreach($holescores as $key => $holescore) { |
|
| 71 | - if($holescore['round']['match_id'] != null){ |
|
| 72 | - if( ($holescore['hole']['par'] - $holescore['score']) === 1) { |
|
| 73 | - $allBirdies[]= $holescore['round']['player']['id']; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - return count(array_keys($allBirdies, $playerId)); |
|
| 62 | + public function totalBirdies($playerId){} |
|
| 63 | + public function birdiesByYear($playerId, $year) |
|
| 64 | + { |
|
| 65 | + $year = $year . '-01-01'; |
|
| 66 | + $holescores = Holescore::with('round.player','hole') |
|
| 67 | + ->where('created_at', '>', $year) |
|
| 68 | + ->get(); |
|
| 69 | + $allBirdies = array(); |
|
| 70 | + foreach($holescores as $key => $holescore) { |
|
| 71 | + if($holescore['round']['match_id'] != null){ |
|
| 72 | + if( ($holescore['hole']['par'] - $holescore['score']) === 1) { |
|
| 73 | + $allBirdies[]= $holescore['round']['player']['id']; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + return count(array_keys($allBirdies, $playerId)); |
|
| 78 | 78 | |
| 79 | - } |
|
| 80 | - public function birdiesMatchesByYear($year){} |
|
| 79 | + } |
|
| 80 | + public function birdiesMatchesByYear($year){} |
|
| 81 | 81 | |
| 82 | - public function totalPars(){} |
|
| 83 | - public function parsByYear($year){} |
|
| 84 | - public function parsMatchesByYear($year){} |
|
| 82 | + public function totalPars(){} |
|
| 83 | + public function parsByYear($year){} |
|
| 84 | + public function parsMatchesByYear($year){} |
|
| 85 | 85 | |
| 86 | - public function totalbogeys(){} |
|
| 87 | - public function bogeysByYear($year){} |
|
| 88 | - public function bogeysMatchesByYear($year){} |
|
| 86 | + public function totalbogeys(){} |
|
| 87 | + public function bogeysByYear($year){} |
|
| 88 | + public function bogeysMatchesByYear($year){} |
|
| 89 | 89 | |
| 90 | - public function totalDoubles(){} |
|
| 91 | - public function doublesByYear($year){} |
|
| 92 | - public function doublesMatchesByYear($year){} |
|
| 90 | + public function totalDoubles(){} |
|
| 91 | + public function doublesByYear($year){} |
|
| 92 | + public function doublesMatchesByYear($year){} |
|
| 93 | 93 | |
| 94 | - public function totalOthers(){} |
|
| 95 | - public function othersByYear($year){} |
|
| 96 | - public function othersMatchesByYear($year){} |
|
| 94 | + public function totalOthers(){} |
|
| 95 | + public function othersByYear($year){} |
|
| 96 | + public function othersMatchesByYear($year){} |
|
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | \ No newline at end of file |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | Route::get('/', function() |
| 14 | 14 | { |
| 15 | - return Redirect::to('schedule'); |
|
| 15 | + return Redirect::to('schedule'); |
|
| 16 | 16 | }); |
| 17 | 17 | /* |
| 18 | 18 | Route::get('/test', function() |
@@ -70,12 +70,12 @@ |
||
| 70 | 70 | |
| 71 | 71 | // Logic to allow editable for day of match and next day |
| 72 | 72 | // after the 2nd day the match page will be read only |
| 73 | - $today=date_create(date('Y-m-d')); |
|
| 74 | - $matchDate=date_create($data['date']); |
|
| 75 | - $diff=date_diff($today,$matchDate); |
|
| 73 | + $today = date_create(date('Y-m-d')); |
|
| 74 | + $matchDate = date_create($data['date']); |
|
| 75 | + $diff = date_diff($today, $matchDate); |
|
| 76 | 76 | $dateDiff = $diff->format("%a"); |
| 77 | 77 | |
| 78 | - if($dateDiff <= 1){ |
|
| 78 | + if ($dateDiff <= 1) { |
|
| 79 | 79 | //Show Editable View |
| 80 | 80 | $view = View::make('EnterMatch', $data); |
| 81 | 81 | return $view; |
@@ -75,12 +75,11 @@ |
||
| 75 | 75 | $diff=date_diff($today,$matchDate); |
| 76 | 76 | $dateDiff = $diff->format("%a"); |
| 77 | 77 | |
| 78 | - if($dateDiff <= 1){ |
|
| 78 | + if($dateDiff <= 1) { |
|
| 79 | 79 | //Show Editable View |
| 80 | 80 | $view = View::make('EnterMatch', $data); |
| 81 | 81 | return $view; |
| 82 | - } |
|
| 83 | - else { |
|
| 82 | + } else { |
|
| 84 | 83 | //Show Readonly View |
| 85 | 84 | $view = View::make('ViewMatch', $data); |
| 86 | 85 | return $view; |
@@ -4,12 +4,12 @@ |
||
| 4 | 4 | |
| 5 | 5 | class MatchEditController extends \BaseController { |
| 6 | 6 | |
| 7 | - public function __construct(MatchRepository $matchRepository) |
|
| 8 | - { |
|
| 9 | - $this->matchRepo = $matchRepository; |
|
| 10 | - } |
|
| 7 | + public function __construct(MatchRepository $matchRepository) |
|
| 8 | + { |
|
| 9 | + $this->matchRepo = $matchRepository; |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - /** |
|
| 12 | + /** |
|
| 13 | 13 | * Display a listing of the resource. |
| 14 | 14 | * |
| 15 | 15 | * @return Response |