@@ -4,7 +4,7 @@ |
||
| 4 | 4 | use Xoco70\LaravelTournaments\Models\Championship; |
| 5 | 5 | use Xoco70\LaravelTournaments\Models\Competitor; |
| 6 | 6 | |
| 7 | -$factory->define(Competitor::class, function (Faker\Generator $faker) { |
|
| 7 | +$factory->define(Competitor::class, function(Faker\Generator $faker) { |
|
| 8 | 8 | $tcs = Championship::all()->pluck('id')->toArray(); |
| 9 | 9 | $users = User::all()->pluck('id')->toArray(); |
| 10 | 10 | $championshipId = $faker->randomElement($tcs); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::table('users', function ($table) { |
|
| 16 | + Schema::table('users', function($table) { |
|
| 17 | 17 | $table->string('firstname')->default('firstname'); |
| 18 | 18 | $table->string('lastname')->default('lastname'); |
| 19 | 19 | }); |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | DBHelpers::setFKCheckOff(); |
| 30 | 30 | if (Schema::hasColumn('users', 'firstname')) { |
| 31 | - Schema::table('users', function (Blueprint $table) { |
|
| 31 | + Schema::table('users', function(Blueprint $table) { |
|
| 32 | 32 | $table->dropColumn('firstname'); |
| 33 | 33 | }); |
| 34 | 34 | } |
| 35 | 35 | if (Schema::hasColumn('users', 'lastname')) { |
| 36 | - Schema::table('users', function (Blueprint $table) { |
|
| 36 | + Schema::table('users', function(Blueprint $table) { |
|
| 37 | 37 | $table->dropColumn('lastname'); |
| 38 | 38 | }); |
| 39 | 39 | } |
@@ -16,18 +16,18 @@ |
||
| 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, 'laravel-tournaments'); |
| 21 | 21 | |
| 22 | - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
| 23 | - $this->loadTranslationsFrom(__DIR__.'/../translations', 'laravel-tournaments'); |
|
| 22 | + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
|
| 23 | + $this->loadTranslationsFrom(__DIR__ . '/../translations', 'laravel-tournaments'); |
|
| 24 | 24 | |
| 25 | - $this->publishes([__DIR__.'/../database/migrations' => $this->app->databasePath().'/migrations'], 'laravel-tournaments'); |
|
| 26 | - $this->publishes([__DIR__.'/../database/seeds' => $this->app->databasePath().'/seeds'], 'laravel-tournaments'); |
|
| 27 | - $this->publishes([__DIR__.'/../database/factories' => $this->app->databasePath().'/factories'], 'laravel-tournaments'); |
|
| 28 | - $this->publishes([__DIR__.'/../resources/assets' => public_path('vendor/laravel-tournaments')], 'laravel-tournaments'); |
|
| 25 | + $this->publishes([__DIR__ . '/../database/migrations' => $this->app->databasePath() . '/migrations'], 'laravel-tournaments'); |
|
| 26 | + $this->publishes([__DIR__ . '/../database/seeds' => $this->app->databasePath() . '/seeds'], 'laravel-tournaments'); |
|
| 27 | + $this->publishes([__DIR__ . '/../database/factories' => $this->app->databasePath() . '/factories'], 'laravel-tournaments'); |
|
| 28 | + $this->publishes([__DIR__ . '/../resources/assets' => public_path('vendor/laravel-tournaments')], 'laravel-tournaments'); |
|
| 29 | 29 | |
| 30 | - $router->group(['prefix' => 'laravel-tournaments', 'middleware' => ['web']], function ($router) { |
|
| 30 | + $router->group(['prefix' => 'laravel-tournaments', 'middleware' => ['web']], function($router) { |
|
| 31 | 31 | $router->get('/', 'Xoco70\LaravelTournaments\TreeController@index')->name('tree.index'); |
| 32 | 32 | $router->post('/championships/{championship}/trees', 'Xoco70\LaravelTournaments\TreeController@store')->name('tree.store'); |
| 33 | 33 | $router->put('/championships/{championship}/trees', 'Xoco70\LaravelTournaments\TreeController@update')->name('tree.update'); |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -$topOffset = ($numRound == 1 ? 0 : (pow(2, $numRound-1)-1) * 51); |
|
| 2 | +$topOffset = ($numRound == 1 ? 0 : (pow(2, $numRound - 1) - 1) * 51); |
|
| 3 | 3 | $top = \App\Bracket::getTopFight($numRound, $numFight) + $topOffset; |
| 4 | 4 | |
| 5 | 5 | $left = \App\Bracket::getLeftFight($numRound); |
@@ -4,10 +4,10 @@ |
||
| 4 | 4 | use Xoco70\LaravelTournaments\Models\Championship; |
| 5 | 5 | use Xoco70\LaravelTournaments\Models\ChampionshipSettings; |
| 6 | 6 | |
| 7 | -$factory->define(ChampionshipSettings::class, function (Faker\Generator $faker) use ($factory) { |
|
| 7 | +$factory->define(ChampionshipSettings::class, function(Faker\Generator $faker) use ($factory) { |
|
| 8 | 8 | $tcs = Championship::all()->pluck('id')->toArray(); |
| 9 | 9 | |
| 10 | - $fightingAreas = [1,2,4,8]; |
|
| 10 | + $fightingAreas = [1, 2, 4, 8]; |
|
| 11 | 11 | return [ |
| 12 | 12 | 'championship_id' => $faker->randomElement($tcs), |
| 13 | 13 | 'treeType' => $faker->numberBetween(0, 1), |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | $this->groupsByRound = $groupsByRound; |
| 27 | 27 | $this->hasPreliminary = $hasPreliminary; |
| 28 | 28 | |
| 29 | - $this->firstRoundName = $groupsByRound->first()->map(function ($item) use ($championship) { |
|
| 29 | + $this->firstRoundName = $groupsByRound->first()->map(function($item) use ($championship) { |
|
| 30 | 30 | $fighters = $item->getFightersWithBye(); |
| 31 | 31 | $fighter1 = $fighters->get(0); |
| 32 | 32 | $fighter2 = $fighters->get(1); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @param $fightersByEntity |
| 32 | 32 | * |
| 33 | - * @return mixed |
|
| 33 | + * @return Collection |
|
| 34 | 34 | */ |
| 35 | 35 | protected function chunkAndShuffle(Collection $fightersByEntity) |
| 36 | 36 | { |
@@ -97,6 +97,9 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | + /** |
|
| 101 | + * @param integer $round |
|
| 102 | + */ |
|
| 100 | 103 | protected function generateGroupsForRound(Collection $fightersByArea, $round) |
| 101 | 104 | { |
| 102 | 105 | $fightersId = $fightersByArea->pluck('id'); |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | $prefix = "singleElimination"; |
| 3 | -if ($championship->hasPreliminary() && $roundNumber ==1){ |
|
| 3 | +if ($championship->hasPreliminary() && $roundNumber == 1) { |
|
| 4 | 4 | $prefix = "preliminary"; |
| 5 | 5 | } |
| 6 | -$className = $prefix."_select"; |
|
| 7 | -$selectName = $prefix."_fighters[]"; |
|
| 6 | +$className = $prefix . "_select"; |
|
| 7 | +$selectName = $prefix . "_fighters[]"; |
|
| 8 | 8 | |
| 9 | 9 | ?> |
| 10 | 10 | <!-- r = round, m = match, f = fighter --> |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @param Request $request |
| 39 | 39 | * |
| 40 | - * @return \Illuminate\Http\Response|string |
|
| 40 | + * @return \Illuminate\Http\RedirectResponse |
|
| 41 | 41 | */ |
| 42 | 42 | public function store(Request $request, $championshipId) |
| 43 | 43 | { |
@@ -137,6 +137,9 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | |
| 140 | + /** |
|
| 141 | + * @param integer $numFighter |
|
| 142 | + */ |
|
| 140 | 143 | function getWinnerId($fighters, $scores, $numFighter) |
| 141 | 144 | { |
| 142 | 145 | return $scores[$numFighter] != null ? $fighters[$numFighter] : null; |