Package Data | |
---|---|
Maintainer Username: | xoco |
Maintainer Contact: | julien@cappiello.fr (juliatzin) |
Package Create Date: | 2017-02-09 |
Package Last Update: | 2023-09-19 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:04:26 |
Package Statistics | |
---|---|
Total Downloads: | 468 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 230 |
Total Watchers: | 17 |
Total Forks: | 51 |
Total Open Issues: | 11 |
This is still a work in progress. Things could change, things could break. Use it at your own risks in production
NOTE: Depending on your version of Laravel, you should install a different version of the package:
| Laravel Version | Laravel Tournament Version | |:---------------:|:--------------------------:| | 5.8 | 0.16 | | 5.7 | 0.15 | | 5.6 | 0.14 | | 5.5 | 0.13 |
First, you'll need to install the package via Composer:
composer require "xoco70/laravel-tournaments"
Finally, from the command line again, publish the default configuration file:
php artisan vendor:publish --tag=laravel-tournaments --force
If you want to see plugin in action, you can go to: https://demo.kendozone.com/laravel-tournaments
To run the demo, you need to generate Tournaments, Championships, Users, Competitors and Settings
Run Migrations:
php artisan migrate
composer dump-autoload
Seed dummy data:
php artisan db:seed --class=LaravelTournamentSeeder
WARNING: Don't do this in production, it would wipe all your data. Use this line for demo purpose only
You will be able to access the demo at http://yourdomain.com/laravel-tournaments
// Create a tournament
$tournament = factory(Tournament::class)->create(['user_id' => Auth::user()->id]);
$championsip = factory(Championship::class)->create(['$tournament_id' => $tournament->id]);
// Optional, if not defined, it will take default in ChampionshipSettings
$settings = factory(ChampionshipSettings::class)->create(['championship_id' => $championship->id]);
// Add competitors to championship
$competitors = factory(\App\Competitor::class,10)->create([
'championship_id' => $championship->id,
'user_id' => factory(User::class)->create()->id
]);
// Define strategy to generate
$generation = $championship->chooseGenerationStrategy();
// Generate everything
$generation->run();
// Just generate Tree
$this->generateAllTrees();
// Just generate Fight List
$this->generateAllFights();
$tournament->owner; // get owner
$tournament->venue; // get venue
$tournament->championships; // get championships
Check tournament type:
$tournament->isOpen()
$tournament->needsInvitation()
Check tournament level:
$tournament ->isInternational()
$tournament->isNational()
$tournament->isRegional()
$tournament->isEstate()
$tournament->isMunicipal()
$tournament->isDistrictal()
$tournament->isLocal()
$tournament->hasNoLevel()
$championship->competitors; // Get competitors
$championship->teams; // Get teams
$championship->fighters; // Get fighters
$championship->category; // Get category
$championship->tournament; // Get tournament
$championship->users; // Get users
$championship->settings; // Get settings
$championship->fightersGroups; // Get groups
$championship->groupsByRound($numRound = 1); // Get groups for a specific round
$championship->groupsFromRound($numRound = 1); // Get groups from a specific round
$championship->fights; // Get fights
$championship->firstRoundFights; // Get fights for the first round only ( Useful when has preliminary )
$championship->fights($numRound = 1); // Get fights for a specific round
NOTE: $fighter can be an instance of
Team
orCompetitor
Determine strategy:
$championship->isPlayoffCompetitor()
$championship->isPlayoffTeam()
$championship->isSingleEliminationCompetitor()
$championship->isSingleEliminationTeam()
Determine group size:
$championship->getGroupSize()
Determine championship type:
$championship->hasPreliminary()
$championship->isPlayOffType()
$championship->isSingleEliminationType()
$group->championship; // Get championship
$group->fights; // Get fights
$group->fighters; // Get fighters
$group->teams; // Get teams
$group->competitors; // Get competitors
$group->users; // Get users
NOTE: $fighter can be an instance of
Team
orCompetitor
To get the instance name:
$group->getFighterType() // Should return Team::class or Competitor::class
NOTE: This plugin use laravel-nestedset. This means you can navigate with
$group->children()
or$group->parent()
or use any methods available in this great plugin.
$competitor->user; // Get user
// Create a team
$team = factory(Team::class)
->create([ championship_id' => $championship->id]);
// Add competitor to team
$team->competitors()->attach($competitor->id);
// Remove competitor from a team
$team->competitors()->detach($competitor->id);
$fight->group; // Get group
$fight->competitor1; // Get competitor1
$fight->competitor2; // Get competitor2
$fight->team1; // Get team1
$fight->team2; // Get team2
Preliminary tree
@include('laravel-tournaments::partials.tree.preliminary') // Preliminary table
Single Elimination tree
@include('laravel-tournaments::partials.tree.singleElimination', ['hasPreliminary' => 0])
Fight List
@include('laravel-tournaments::partials.fights')
vendor/bin/phpunit tests
This is a work in progress, and tree creation might be very complex, so there is a bunch of things to achieve.
For those running MariaDB or older versions of MySQL you may hit this error when trying to run migrations: As outlined in the Migrations guide to fix this all you have to do is edit your AppServiceProvider.php file and inside the boot method set a default string length:
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
This error means you don't have enough competitors / teams to create given tree Try to increase competitor number, decrease areas or preliminary group size, if preliminary round is active