@@ -23,11 +23,11 @@ |
||
| 23 | 23 | { |
| 24 | 24 | parent::boot(); |
| 25 | 25 | |
| 26 | - static::deleting(function ($championship) { |
|
| 26 | + static::deleting(function($championship) { |
|
| 27 | 27 | $championship->competitors()->delete(); |
| 28 | 28 | $championship->settings()->delete(); |
| 29 | 29 | }); |
| 30 | - static::restoring(function ($championship) { |
|
| 30 | + static::restoring(function($championship) { |
|
| 31 | 31 | $championship->competitors()->restore(); |
| 32 | 32 | $championship->settings()->restore(); |
| 33 | 33 | }); |
@@ -149,8 +149,9 @@ |
||
| 149 | 149 | { |
| 150 | 150 | |
| 151 | 151 | |
| 152 | - if ($this->settings != null && $this->settings->alias != null && $this->settings->alias != '') |
|
| 153 | - return $this->settings->alias; |
|
| 152 | + if ($this->settings != null && $this->settings->alias != null && $this->settings->alias != '') { |
|
| 153 | + return $this->settings->alias; |
|
| 154 | + } |
|
| 154 | 155 | |
| 155 | 156 | $genders = [ |
| 156 | 157 | 'M' => trans('categories.male'), |
@@ -56,13 +56,13 @@ |
||
| 56 | 56 | protected static function boot() |
| 57 | 57 | { |
| 58 | 58 | parent::boot(); |
| 59 | - static::deleting(function ($tournament) { |
|
| 59 | + static::deleting(function($tournament) { |
|
| 60 | 60 | foreach ($tournament->championships as $ct) { |
| 61 | 61 | $ct->delete(); |
| 62 | 62 | } |
| 63 | 63 | $tournament->invites()->delete(); |
| 64 | 64 | }); |
| 65 | - static::restoring(function ($tournament) { |
|
| 65 | + static::restoring(function($tournament) { |
|
| 66 | 66 | foreach ($tournament->championships()->withTrashed()->get() as $ct) { |
| 67 | 67 | $ct->restore(); |
| 68 | 68 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('championship_settings', function (Blueprint $table) { |
|
| 15 | + Schema::create('championship_settings', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | 17 | $table->string('alias')->nullable(); |
| 18 | 18 | $table->integer('championship_id')->unsigned()->unique(); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('category', function (Blueprint $table) { |
|
| 15 | + Schema::create('category', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | 17 | $table->string('name'); |
| 18 | 18 | $table->string('gender')->nullable(); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $table->engine = 'InnoDB'; |
| 35 | 35 | }); |
| 36 | 36 | |
| 37 | - Schema::create('championship', function (Blueprint $table) { |
|
| 37 | + Schema::create('championship', function(Blueprint $table) { |
|
| 38 | 38 | $table->increments('id'); |
| 39 | 39 | $table->integer('tournament_id')->unsigned()->index(); |
| 40 | 40 | $table->integer('category_id')->unsigned()->index(); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $table->engine = 'InnoDB'; |
| 57 | 57 | }); |
| 58 | 58 | |
| 59 | - Schema::create('competitor', function (Blueprint $table) { |
|
| 59 | + Schema::create('competitor', function(Blueprint $table) { |
|
| 60 | 60 | $table->increments('id'); |
| 61 | 61 | $table->integer('championship_id')->unsigned()->index(); |
| 62 | 62 | $table->foreign('championship_id') |
@@ -75,11 +75,11 @@ |
||
| 75 | 75 | Round::generateFights($rounds, $settings, $championship); |
| 76 | 76 | } catch (TreeGenerationException $e) { |
| 77 | 77 | redirect()->back() |
| 78 | - ->withErrors([$numFighters ."-".$e->getMessage()]); |
|
| 78 | + ->withErrors([$numFighters . "-" . $e->getMessage()]); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | return redirect()->back() |
| 82 | 82 | ->with('numFighters', $numFighters) |
| 83 | - ->with(['success' , "Success"]); |
|
| 83 | + ->with(['success', "Success"]); |
|
| 84 | 84 | } |
| 85 | 85 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | //Make sure there's at least 2 teams |
| 37 | 37 | |
| 38 | - if(count($teams) == 1){ |
|
| 38 | + if (count($teams) == 1) { |
|
| 39 | 39 | $teams[] = 'Team 2'; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -45,21 +45,21 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | //Calculate the size of the first full round - for example if you have 5 teams, then the first full round will consist of 4 teams |
| 48 | - $minimumFirstRoundSize = pow(2, ceil(log($this->noTeams)/log(2))); |
|
| 48 | + $minimumFirstRoundSize = pow(2, ceil(log($this->noTeams) / log(2))); |
|
| 49 | 49 | $this->noRounds = log($minimumFirstRoundSize, 2); |
| 50 | 50 | $noByesToAdd = $minimumFirstRoundSize - $this->noTeams; |
| 51 | 51 | |
| 52 | 52 | //Add the byes to the teams array |
| 53 | - for($i = 0; $i < $noByesToAdd; $i++){ |
|
| 53 | + for ($i = 0; $i < $noByesToAdd; $i++) { |
|
| 54 | 54 | $teams[] = null; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | //Order the teams in a seeded order - this is required regardless of whether it is a seeded tournament or not, as it prevents BYEs playing eachother |
| 58 | - for($i = 0; $i < log($this->noTeams / 2, 2); $i++){ |
|
| 58 | + for ($i = 0; $i < log($this->noTeams / 2, 2); $i++) { |
|
| 59 | 59 | |
| 60 | 60 | $out = array(); |
| 61 | 61 | |
| 62 | - foreach($teams as $player){ |
|
| 62 | + foreach ($teams as $player) { |
|
| 63 | 63 | $splice = pow(2, $i); |
| 64 | 64 | $out = array_merge($out, array_splice($teams, 0, $splice)); |
| 65 | 65 | $out = array_merge($out, array_splice($teams, -$splice)); |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | $matches = array_chunk($teams, 2); |
| 92 | 92 | |
| 93 | 93 | //Only check for BYEs if there are more than 2 teams |
| 94 | - if($this->noTeams > 2){ |
|
| 94 | + if ($this->noTeams > 2) { |
|
| 95 | 95 | |
| 96 | - foreach($matches as $key => &$match){ |
|
| 96 | + foreach ($matches as $key => &$match) { |
|
| 97 | 97 | |
| 98 | 98 | $matchNumber = $key + 1; |
| 99 | 99 | |
| 100 | 100 | //If both teams are present, then that means they haven't had a BYE to the next round, so they must play in the first round |
| 101 | - if($match[0] && $match[1]){ |
|
| 101 | + if ($match[0] && $match[1]) { |
|
| 102 | 102 | |
| 103 | 103 | //Add the match to the first round |
| 104 | 104 | $this->brackets[$roundNumber][$matchNumber] = $match; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | //Set the match to null as the result of the above match hasn't yet been determined |
| 107 | 107 | $match = null; |
| 108 | 108 | |
| 109 | - }else{ |
|
| 109 | + } else { |
|
| 110 | 110 | |
| 111 | 111 | //If only the first or second player exists, then replace the multidimensional array with the existing player |
| 112 | 112 | $match = $match[0] ? $match[0] : $match[1]; |
@@ -121,17 +121,17 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | //If there's already a match in the match array, then that means the next round is round 2, so increase the round number |
| 124 | - if(count($this->brackets)) $roundNumber++; |
|
| 124 | + if (count($this->brackets)) $roundNumber++; |
|
| 125 | 125 | |
| 126 | 126 | //Create the first full round of teams, some may be blank if waiting on the results of a previous round |
| 127 | - for($i = 0; $i < count($matches); $i++){ |
|
| 128 | - $this->brackets[$roundNumber][$i+1] = $matches[$i]; |
|
| 127 | + for ($i = 0; $i < count($matches); $i++) { |
|
| 128 | + $this->brackets[$roundNumber][$i + 1] = $matches[$i]; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | //Create the result of the empty rows for this tournament |
| 132 | 132 | |
| 133 | - for($roundNumber += 1; $roundNumber <= $this->noRounds; $roundNumber++){ |
|
| 134 | - for($matchNumber = 1; $matchNumber <= ($minimumFirstRoundSize/pow(2, $roundNumber)); $matchNumber++){ |
|
| 133 | + for ($roundNumber += 1; $roundNumber <= $this->noRounds; $roundNumber++) { |
|
| 134 | + for ($matchNumber = 1; $matchNumber <= ($minimumFirstRoundSize / pow(2, $roundNumber)); $matchNumber++) { |
|
| 135 | 135 | $this->brackets[$roundNumber][$matchNumber] = array(null, null); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | $matchSpacingMultiplier = 0.5; |
| 149 | 149 | $playerWrapperHeightMultiplier = 1; |
| 150 | 150 | |
| 151 | - foreach($this->brackets as $roundNumber => &$round){ |
|
| 151 | + foreach ($this->brackets as $roundNumber => &$round) { |
|
| 152 | 152 | |
| 153 | - foreach($round as $matchNumber => &$match){ |
|
| 153 | + foreach ($round as $matchNumber => &$match) { |
|
| 154 | 154 | |
| 155 | 155 | //Give teams a nicer index |
| 156 | 156 | |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | //Adjust the positions depending on the match number |
| 174 | 174 | |
| 175 | - if(!($matchNumber % 2)){ |
|
| 175 | + if (!($matchNumber % 2)) { |
|
| 176 | 176 | $match['hConnector2Top'] = $match['vConnectorTop'] -= ($match['vConnectorHeight'] - $this->borderWidth); |
| 177 | - }else{ |
|
| 177 | + } else { |
|
| 178 | 178 | $match['hConnector2Top'] = $match['vConnectorTop'] + ($match['vConnectorHeight'] - $this->borderWidth); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -196,24 +196,24 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | echo '<div id="brackets-wrapper">'; |
| 198 | 198 | |
| 199 | - foreach($this->brackets as $roundNumber => $round) { |
|
| 199 | + foreach ($this->brackets as $roundNumber => $round) { |
|
| 200 | 200 | |
| 201 | - foreach($round as $matchNumber => $match) { |
|
| 201 | + foreach ($round as $matchNumber => $match) { |
|
| 202 | 202 | |
| 203 | - echo '<div class="match-wrapper" style="top: '.$match['matchWrapperTop'].'px; left: '.$match['matchWrapperLeft'].'px; width: '.$this->matchWrapperWidth.'px;"> |
|
| 203 | + echo '<div class="match-wrapper" style="top: ' . $match['matchWrapperTop'] . 'px; left: ' . $match['matchWrapperLeft'] . 'px; width: ' . $this->matchWrapperWidth . 'px;"> |
|
| 204 | 204 | <input type="text" class="score">' |
| 205 | - .$this->getPlayerList($match['playerA']). |
|
| 205 | + .$this->getPlayerList($match['playerA']) . |
|
| 206 | 206 | '<div class="match-divider"> |
| 207 | 207 | </div> |
| 208 | 208 | <input type="text" class="score">' |
| 209 | - .$this->getPlayerList($match['playerB']). |
|
| 209 | + .$this->getPlayerList($match['playerB']) . |
|
| 210 | 210 | '</div>'; |
| 211 | 211 | |
| 212 | 212 | if ($roundNumber != $this->noRounds) { |
| 213 | 213 | |
| 214 | - echo '<div class="vertical-connector" style="top: '.$match['vConnectorTop'].'px; left: '.$match['vConnectorLeft'].'px; height: '.$match['vConnectorHeight'].'px;"></div> |
|
| 215 | - <div class="horizontal-connector" style="top: '.$match['hConnectorTop'].'px; left: '.$match['hConnectorLeft'].'px;"></div> |
|
| 216 | - <div class="horizontal-connector" style="top: '.$match['hConnector2Top'].'px; left: '.$match['hConnector2Left'].'px;"></div>'; |
|
| 214 | + echo '<div class="vertical-connector" style="top: ' . $match['vConnectorTop'] . 'px; left: ' . $match['vConnectorLeft'] . 'px; height: ' . $match['vConnectorHeight'] . 'px;"></div> |
|
| 215 | + <div class="horizontal-connector" style="top: '.$match['hConnectorTop'] . 'px; left: ' . $match['hConnectorLeft'] . 'px;"></div> |
|
| 216 | + <div class="horizontal-connector" style="top: '.$match['hConnector2Top'] . 'px; left: ' . $match['hConnector2Left'] . 'px;"></div>'; |
|
| 217 | 217 | |
| 218 | 218 | } |
| 219 | 219 | |
@@ -225,31 +225,31 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - private function printRoundTitles(){ |
|
| 228 | + private function printRoundTitles() { |
|
| 229 | 229 | |
| 230 | - if($this->noTeams == 2){ |
|
| 230 | + if ($this->noTeams == 2) { |
|
| 231 | 231 | |
| 232 | 232 | $roundTitles = array('Final'); |
| 233 | 233 | |
| 234 | - }elseif($this->noTeams <= 4){ |
|
| 234 | + }elseif ($this->noTeams <= 4) { |
|
| 235 | 235 | |
| 236 | 236 | $roundTitles = array('Semi-Finals', 'Final'); |
| 237 | 237 | |
| 238 | - }elseif($this->noTeams <= 8){ |
|
| 238 | + }elseif ($this->noTeams <= 8) { |
|
| 239 | 239 | |
| 240 | 240 | $roundTitles = array('Quarter-Finals', 'Semi-Finals', 'Final'); |
| 241 | 241 | |
| 242 | - }else{ |
|
| 242 | + } else { |
|
| 243 | 243 | |
| 244 | 244 | $roundTitles = array('Quarter-Finals', 'Semi-Finals', 'Final'); |
| 245 | 245 | $noRounds = ceil(log($this->noTeams, 2)); |
| 246 | - $noTeamsInFirstRound = pow(2, ceil(log($this->noTeams)/log(2))); |
|
| 246 | + $noTeamsInFirstRound = pow(2, ceil(log($this->noTeams) / log(2))); |
|
| 247 | 247 | $tempRounds = array(); |
| 248 | 248 | |
| 249 | 249 | //The minus 3 is to ignore the final, semi final and quarter final rounds |
| 250 | 250 | |
| 251 | - for($i = 0; $i < $noRounds - 3; $i++){ |
|
| 252 | - $tempRounds[] = 'Last '.$noTeamsInFirstRound; |
|
| 251 | + for ($i = 0; $i < $noRounds - 3; $i++) { |
|
| 252 | + $tempRounds[] = 'Last ' . $noTeamsInFirstRound; |
|
| 253 | 253 | $noTeamsInFirstRound /= 2; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | echo '<div id="round-titles-wrapper">'; |
| 261 | 261 | |
| 262 | - foreach($roundTitles as $key => $roundTitle) { |
|
| 262 | + foreach ($roundTitles as $key => $roundTitle) { |
|
| 263 | 263 | |
| 264 | 264 | $left = $key * ($this->matchWrapperWidth + $this->roundSpacing - 1); |
| 265 | 265 | |
| 266 | - echo '<div class="round-title" style="left: '.$left.'px;">' . $roundTitle . '</div>'; |
|
| 266 | + echo '<div class="round-title" style="left: ' . $left . 'px;">' . $roundTitle . '</div>'; |
|
| 267 | 267 | |
| 268 | 268 | } |
| 269 | 269 | |
@@ -275,16 +275,16 @@ discard block |
||
| 275 | 275 | { |
| 276 | 276 | |
| 277 | 277 | $html = '<select> |
| 278 | - <option'.($selected == '' ? ' selected' : '').'></option>'; |
|
| 278 | + <option'.($selected == '' ? ' selected' : '') . '></option>'; |
|
| 279 | 279 | |
| 280 | - foreach(array_merge($this->brackets[1], $this->brackets[2]) as $bracket){ |
|
| 280 | + foreach (array_merge($this->brackets[1], $this->brackets[2]) as $bracket) { |
|
| 281 | 281 | |
| 282 | - if($bracket['playerA'] != ''){ |
|
| 283 | - $html .= '<option'.($selected == $bracket['playerA'] ? ' selected' : '').'>'.$bracket['playerA'].'</option>'; |
|
| 282 | + if ($bracket['playerA'] != '') { |
|
| 283 | + $html .= '<option' . ($selected == $bracket['playerA'] ? ' selected' : '') . '>' . $bracket['playerA'] . '</option>'; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - if($bracket['playerB'] != ''){ |
|
| 287 | - $html .= '<option'.($selected == $bracket['playerB'] ? ' selected' : '').'>'.$bracket['playerB'].'</option>'; |
|
| 286 | + if ($bracket['playerB'] != '') { |
|
| 287 | + $html .= '<option' . ($selected == $bracket['playerB'] ? ' selected' : '') . '>' . $bracket['playerB'] . '</option>'; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | //Set the match to null as the result of the above match hasn't yet been determined |
| 107 | 107 | $match = null; |
| 108 | 108 | |
| 109 | - }else{ |
|
| 109 | + } else{ |
|
| 110 | 110 | |
| 111 | 111 | //If only the first or second player exists, then replace the multidimensional array with the existing player |
| 112 | 112 | $match = $match[0] ? $match[0] : $match[1]; |
@@ -121,7 +121,9 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | //If there's already a match in the match array, then that means the next round is round 2, so increase the round number |
| 124 | - if(count($this->brackets)) $roundNumber++; |
|
| 124 | + if(count($this->brackets)) { |
|
| 125 | + $roundNumber++; |
|
| 126 | + } |
|
| 125 | 127 | |
| 126 | 128 | //Create the first full round of teams, some may be blank if waiting on the results of a previous round |
| 127 | 129 | for($i = 0; $i < count($matches); $i++){ |
@@ -174,7 +176,7 @@ discard block |
||
| 174 | 176 | |
| 175 | 177 | if(!($matchNumber % 2)){ |
| 176 | 178 | $match['hConnector2Top'] = $match['vConnectorTop'] -= ($match['vConnectorHeight'] - $this->borderWidth); |
| 177 | - }else{ |
|
| 179 | + } else{ |
|
| 178 | 180 | $match['hConnector2Top'] = $match['vConnectorTop'] + ($match['vConnectorHeight'] - $this->borderWidth); |
| 179 | 181 | } |
| 180 | 182 | |
@@ -231,15 +233,15 @@ discard block |
||
| 231 | 233 | |
| 232 | 234 | $roundTitles = array('Final'); |
| 233 | 235 | |
| 234 | - }elseif($this->noTeams <= 4){ |
|
| 236 | + } elseif($this->noTeams <= 4){ |
|
| 235 | 237 | |
| 236 | 238 | $roundTitles = array('Semi-Finals', 'Final'); |
| 237 | 239 | |
| 238 | - }elseif($this->noTeams <= 8){ |
|
| 240 | + } elseif($this->noTeams <= 8){ |
|
| 239 | 241 | |
| 240 | 242 | $roundTitles = array('Quarter-Finals', 'Semi-Finals', 'Final'); |
| 241 | 243 | |
| 242 | - }else{ |
|
| 244 | + } else{ |
|
| 243 | 245 | |
| 244 | 246 | $roundTitles = array('Quarter-Finals', 'Semi-Finals', 'Final'); |
| 245 | 247 | $noRounds = ceil(log($this->noTeams, 2)); |
@@ -16,20 +16,20 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function boot(Router $router) |
| 18 | 18 | { |
| 19 | - $viewPath = __DIR__.'/../resources/views'; |
|
| 19 | + $viewPath = __DIR__ . '/../resources/views'; |
|
| 20 | 20 | $this->loadViewsFrom($viewPath, 'kendo-tournaments'); |
| 21 | 21 | // $this->publishes([ $viewPath => base_path('resources/views/vendor/kendo-tournaments'),], 'kendo-tournaments'); |
| 22 | 22 | |
| 23 | - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
| 24 | - $this->loadTranslationsFrom(__DIR__.'/../translations', 'kendo-tournaments'); |
|
| 23 | + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
|
| 24 | + $this->loadTranslationsFrom(__DIR__ . '/../translations', 'kendo-tournaments'); |
|
| 25 | 25 | |
| 26 | 26 | // $this->publishes([__DIR__ . '/views' => base_path('resources/views/vendor/kendo-tournaments')]); |
| 27 | - $this->publishes([__DIR__.'/../database/migrations' => $this->app->databasePath().'/migrations'], 'migrations'); |
|
| 28 | - $this->publishes([__DIR__.'/../database/seeds' => $this->app->databasePath().'/seeds'], 'seeds'); |
|
| 29 | - $this->publishes([__DIR__.'/../database/factories' => $this->app->databasePath().'/factories'], 'seeds'); |
|
| 30 | - $this->publishes([__DIR__.'/../resources/assets' => public_path('vendor/kendo-tournaments')], 'assets'); |
|
| 27 | + $this->publishes([__DIR__ . '/../database/migrations' => $this->app->databasePath() . '/migrations'], 'migrations'); |
|
| 28 | + $this->publishes([__DIR__ . '/../database/seeds' => $this->app->databasePath() . '/seeds'], 'seeds'); |
|
| 29 | + $this->publishes([__DIR__ . '/../database/factories' => $this->app->databasePath() . '/factories'], 'seeds'); |
|
| 30 | + $this->publishes([__DIR__ . '/../resources/assets' => public_path('vendor/kendo-tournaments')], 'assets'); |
|
| 31 | 31 | |
| 32 | - $router->group(['prefix' => 'kendo-tournaments', 'middleware' => ['web']], function ($router) { |
|
| 32 | + $router->group(['prefix' => 'kendo-tournaments', 'middleware' => ['web']], function($router) { |
|
| 33 | 33 | $router->get('/', 'Xoco70\KendoTournaments\TreeController@index')->name('tree.index'); |
| 34 | 34 | $router->post('/championships/{championship}/trees', 'Xoco70\KendoTournaments\TreeController@store')->name('tree.index'); |
| 35 | 35 | }); |