PHPackages                             xoco70/laravel-tournaments - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xoco70/laravel-tournaments

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xoco70/laravel-tournaments
==========================

A Laravel 5.4+ Package that allows you to generate Tournaments tree

0.17(2y ago)23123.3k54[7 issues](https://github.com/xoco70/laravel-tournaments/issues)[4 PRs](https://github.com/xoco70/laravel-tournaments/pulls)MITPHPPHP &gt;=7.4

Since Aug 27Pushed 2y ago15 watchersCompare

[ Source](https://github.com/xoco70/laravel-tournaments)[ Packagist](https://packagist.org/packages/xoco70/laravel-tournaments)[ Docs](https://github.com/xoco70/laravel-tournaments)[ RSS](/packages/xoco70-laravel-tournaments/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)Dependencies (8)Versions (27)Used By (0)

[![Laravel Tournaments](https://raw.githubusercontent.com/xoco70/laravel-tournaments/master/resources/assets/images/logo.png)](https://raw.githubusercontent.com/xoco70/laravel-tournaments/master/resources/assets/images/logo.png)
Laravel Tournaments

===========================================================================================================================================================================================================================================================

[](#laravel-tournaments)

#### A Laravel plugin that generate tournaments out of the box

[](#a-laravel-plugin-that-generate-tournaments-out-of-the-box)

[![Latest Stable Version](https://camo.githubusercontent.com/b3b5869cecc49cf5eed0689dd2ea79a32f6b8e9189470cc9b39c5136ee107818/68747470733a2f2f706f7365722e707567782e6f72672f786f636f37302f6c61726176656c2d746f75726e616d656e74732f762f737461626c65)](https://packagist.org/packages/xoco70/laravel-tournaments)[![Total Downloads](https://camo.githubusercontent.com/c080325808184ea225fa6d89d4e4db906cfe8e5c98c01b08381c9eef510df27a/68747470733a2f2f706f7365722e707567782e6f72672f786f636f37302f6c61726176656c2d746f75726e616d656e74732f646f776e6c6f616473)](https://packagist.org/packages/xoco70/laravel-tournaments)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/748f74e1dc8cd0a8470d4d84040a4fd5a9db5f0bf14850d9b581b59dc6ac3965/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f786f636f37302f6c61726176656c2d746f75726e616d656e74732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xoco70/laravel-tournaments/?branch=master)[![Build Status](https://camo.githubusercontent.com/289bf26387bd9c90855046de916d3bf237c28d853d59a10d5d18e48e17cb5fcc/68747470733a2f2f7472617669732d63692e6f72672f786f636f37302f6c61726176656c2d746f75726e616d656e74732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/xoco70/laravel-tournaments)[![Code Coverage](https://camo.githubusercontent.com/fb63fac1649cf21fd8dabe8d8ff8550687a5f0ff6a3245e2cabd9e971d90e7bf/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f786f636f37302f6c61726176656c2d746f75726e616d656e74732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xoco70/laravel-tournaments/?branch=master)

[![Laravel Tournaments Demo](https://raw.githubusercontent.com/xoco70/laravel-tournaments/master/resources/assets/images/laravel-tournaments.gif)](https://raw.githubusercontent.com/xoco70/laravel-tournaments/master/resources/assets/images/laravel-tournaments.gif)
========================================================================================================================================================================================================================================================================

[](#)

- [Features](#features)
- [Installation](#installation)
- [Demo](#demo)
- [Usage](#usage)
- [Data Model](#data-model)
- [Models](#models)
- [Include views](#include-views)
- [Limitations](#limitations)
- [Troubleshooting](#troubleshooting)
- [Changelog](#changelog)

Features
--------

[](#features)

- Single Elimination Trees Generation
- Single Elimination with Preliminary Round Generation
- Playoff Generation
- Third place fight
- List of Fights Generation
- Customize Preliminary Round Size
- Customize area number (1,2,4,8)
- Modify Single Elimination Tree generation on the fly
- Use teams instead of competitors

Installation
------------

[](#installation)

> **NOTE**: Depending on your version of Laravel, you should install a different version of the package:
>
> Laravel VersionLaravel Tournament Version80.175.8 -&gt; 70.165.70.155.60.145.50.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
```

Demo
----

[](#demo)

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

Add TreeController ( you can find it in [demo repository](https://github.com/xoco70/laravel-tournaments-demo/blob/master/app/Http/Controllers/TreeController.php))

Add your custom routes

```
Route::get('/', 'App\Http\Controllers\TreeController@index')->name('tree.index');
Route::post('/championships/{championship}/trees', 'App\Http\Controllers\TreeController@store')->name('tree.store');
Route::put('/championships/{championship}/trees', 'App\Http\Controllers\TreeController@update')->name('tree.update');
```

```
php artisan db:seed --class=LaravelTournamentSeeder
```

You will be able to access the demo at `http://yourdomain.com/`

Usage
-----

[](#usage)

```
// 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();
```

Data model
----------

[](#data-model)

[![Database Model](https://raw.githubusercontent.com/xoco70/laravel-tournaments/master/resources/assets/images/laravel-tournaments-database-model.png)](https://raw.githubusercontent.com/xoco70/laravel-tournaments/master/resources/assets/images/laravel-tournaments-database-model.png)

Models
------

[](#models)

### Tournament

[](#tournament)

```
$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
------------

[](#championship)

```
$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` or `Competitor`

Determine strategy:

```
$championship->isPlayoffCompetitor()
$championship->isPlayoffTeam()
$championship->isSingleEliminationCompetitor()
$championship->isSingleEliminationTeam()
```

Determine group size:

```
$championship->getGroupSize()
```

Determine championship type:

```
$championship->hasPreliminary()
$championship->isPlayOffType()
$championship->isSingleEliminationType()
```

### FightersGroup

[](#fightersgroup)

```
$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` or `Competitor`

To get the instance name:

```
$group->getFighterType() // Should return Team::class or Competitor::class
```

> **NOTE**: This plugin use [laravel-nestedset](https://github.com/lazychaser/laravel-nestedset). This means you can navigate with `$group->children()` or `$group->parent()` or use any methods available in this great plugin.

### Competitor

[](#competitor)

```
$competitor->user; // Get user
```

### Team

[](#team)

```
// 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

[](#fight)

```
$fight->group; // Get group
$fight->competitor1; // Get competitor1
$fight->competitor2; // Get competitor2
$fight->team1; // Get team1
$fight->team2; // Get team2
```

Views
-----

[](#views)

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')
```

Run Functional Tests
--------------------

[](#run-functional-tests)

vendor/bin/phpunit tests

Limitations
-----------

[](#limitations)

This is a work in progress, and tree creation might be very complex, so there is a bunch of things to achieve.

- Seed fighter
- Manage more than 1 fighter out of preliminary round
- Modify Preliminary Round generation on the fly
- Use any number of area ( restricted to 1,2,4,8)
- Manage n+1 case : When for instance, there is 17 competitors in a direct elimination tree, there will have 15 BYES. We can improve that making the first match with 3 competitors.
- Double elimination

Troubleshooting
---------------

[](#troubleshooting)

### Specified key was too long error

[](#specified-key-was-too-long-error)

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](https://laravel.com/docs/master/migrations#creating-indexes) 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);
}
```

### With this configuration, you must have at least...

[](#with-this-configuration-you-must-have-at-least)

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

ChangeLog:
----------

[](#changelog)

- v0.17: Update to Laravel 8
- v0.16: Update to Laravel 5.8
- v0.15: Update to Laravel 5.7
- v0.14: Update to Laravel 5.6 / PHP 7.2 support
- v0.13: Manage third place fight
- v0.12: Update to Laravel 5.5
- v0.11: Initial Version

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 95% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~123 days

Recently: every ~451 days

Total

19

Last Release

1015d ago

PHP version history (3 changes)0.11.18PHP &gt;=7.0.0

0.14.0PHP &gt;=7.1.0

0.17PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2585548?v=4)[Xoco Zamora](/maintainers/xoco)[@xoco](https://github.com/xoco)

---

Top Contributors

[![xoco70](https://avatars.githubusercontent.com/u/5855577?v=4)](https://github.com/xoco70 "xoco70 (95 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![jrhenderson1988](https://avatars.githubusercontent.com/u/8791010?v=4)](https://github.com/jrhenderson1988 "jrhenderson1988 (1 commits)")[![RomanGorbatko](https://avatars.githubusercontent.com/u/975959?v=4)](https://github.com/RomanGorbatko "RomanGorbatko (1 commits)")

---

Tags

generatorkendolaravellaravel-5-packagephpsportstournamenttree-structure

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xoco70-laravel-tournaments/health.svg)

```
[![Health](https://phpackages.com/badges/xoco70-laravel-tournaments/health.svg)](https://phpackages.com/packages/xoco70-laravel-tournaments)
```

###  Alternatives

[musonza/chat

Chat Package for Laravel

1.2k267.5k1](/packages/musonza-chat)[unopim/unopim

UnoPim Laravel PIM

10.5k2.2k](/packages/unopim-unopim)[riari/laravel-forum

A Laravel package providing a solid foundation for building discussion forums

65097.7k3](/packages/riari-laravel-forum)[laravel-frontend-presets/material-dashboard

Laravel 11.x Front-end preset for material

263289.1k](/packages/laravel-frontend-presets-material-dashboard)[biostate/filament-menu-builder

An Elegant Menu Builder for FilamentPHP

6522.4k](/packages/biostate-filament-menu-builder)[venturedrake/laravel-crm

A free open source CRM built as a package for laravel projects

42010.0k](/packages/venturedrake-laravel-crm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
