Laravel package to generate sweepstakes using the Round Robin algorithm

Overview

laravel-round-robin

Latest Stable Version Total Downloads License PHP Version Require

Laravel package to generate sweepstakes using the Round Robin algorithm. Supports any number of teams, as long as they are greater than a minimum value specified in the configuration file. Built with Laravel Collections for better handling of arrays.

REQUIREMENTS

INSTALLATION VIA COMPOSER

Step 1: Composer

Run this command line in console.

composer require tonystore/laravel-round-robin

Step 2: Publish Config File

Publish Config File

php artisan vendor:publish --provider="Tonystore\LaravelRoundRobin\LaravelRoundRobinProvider" --tag=round-robin

In your configuration file you can define the following:



return [
     /**
     *----------------------------------------------------------------------
     * Minimum number of teams to generate a schedule
     *----------------------------------------------------------------------
     */
    'min_teams' => 2,
    /**
     *----------------------------------------------------------------------
     * Custom name for the first phase of the schedule.
     *----------------------------------------------------------------------
     */
    'one_phase' => 'one',
    /**
     *----------------------------------------------------------------------
     * Custom name for the return phase of the schedule.
     *----------------------------------------------------------------------
     */
    'way_phase' => 'way',
]

Usage

If you pass it an array of equipment, it will return an array, which contains an array of objects. For each object you will have the home team, away team and the round it belongs to:

['BSC','CSE','LDU','IDV'];

[
  [
    {
      "phase": "one",
      "round": 1,
      "local": "BSC",
      "visitor": "IDV"
    },
    {
      "phase": "one",
      "round": 1,
      "local": "LDU",
      "visitor": "CSE"
    }
  ],
  [
    {
      "phase": "one",
      "round": 2,
      "local": "IDV",
      "visitor": "LDU"
    },
    {
      "phase": "one",
      "round": 2,
      "local": "BSC",
      "visitor": "CSE"
    }
  ],
  [
    {
      "phase": "one",
      "round": 3,
      "local": "CSE",
      "visitor": "IDV"
    },
    {
      "phase": "one",
      "round": 3,
      "local": "BSC",
      "visitor": "LDU"
    }
  ],
]

You can use this package in several ways:

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

$schedule = new RoundRobin($teams);
$schedule->schedule();

With static function:

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

$schedule = RoundRobin::addTeams($teams)->schedule();

OR

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

$schedule = RoundRobin::makeSchedule($teams, null, true, null, false);

With a helper function:

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

schedule($teams, null, true, null, false);

To generate the schedule without shuffling the teams:

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

$schedule = RoundRobin::addTeams($teams)->doNotShuffle()->schedule();

To generate the calendar I shuffle the teams with a seed:

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

$schedule = RoundRobin::addTeams($teams)->shuffle(12)->schedule();

Any of the available options will generate a collection of ready-made rounds, which you can manipulate at will.

To generate the schedule without shuffling the teams:

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

$schedule = RoundRobin::addTeams($teams)->schedule();

$schedule->first(); //It will return the first round available on the connection.

$schedule->last(); //It will return the last round available on the connection.

In the same way you can use all the options available in Laravel Collections. Additionally we added a collection to convert rounds to objects, you can use it in the following way.

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

$schedule = RoundRobin::addTeams($teams)->schedule()->toObject();

$schedule[0][0]->local; //It will return the name of the home team, of the first game, of the first available round.

There is also the option to generate round-trip rounds. Example:

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

$schedule = RoundRobin::addTeams($teams)->doubleRound()->schedule();

You can filter the calendar by the available phases. Example:

$teams = ['BSC','CSE','CUMBAYA','U. CATOLICA','LDU','AUCAS','GUALACEO','ORENSE','CITY','TU','D. CUENCA','MUSHUCRUNA','IDV','DELFIN','MACARA','9 DE OCTUBRE'];

$schedule = RoundRobin::addTeams($teams)->doubleRound()->schedule(); 

$firstLeg = $schedule->firstLeg(); //Will return only for the first leg.

$secondLeg = $schedule->secondLeg(); //Will return only for the second leg.

Coming soon: Laravel Tournaments

You might also like...
A simple helper to generate and display pagination navigation links

Intro to CHocoCode Paginator Friendly PHP paginator to paginate everything This package introduces a different way of pagination handling. You can rea

CC [CREDIT CARD] GENERATE & VALIDATE TOOL !
CC [CREDIT CARD] GENERATE & VALIDATE TOOL !

⚡ CCE THIS TOOL PERMIT YOU TO GENERATE CREDIT CARD & VALIDATE

Generate stubs for any PHP extension.

php-ext-stubs-generator Installation Run $ composer require --dev lctrs/php-ext-stubs-generator Usage $ php vendor/bin/generate-stubs-for-ext extensio

Allows generate class files parse from json and map json to php object, including multi-level and complex objects;

nixihz/php-object Allows generate class files parse from json and map json to php object, including multi-level and complex objects; Installation You

Silverstripe-ideannotator - Generate docblocks for DataObjects, Page, PageControllers and (Data)Extensions

silverstripe-ideannotator This module generates @property, @method and @mixin tags for DataObjects, PageControllers and (Data)Extensions, so ide's lik

A small PHP library to generate YouTube-like ids from numbers.
A small PHP library to generate YouTube-like ids from numbers.

A small PHP library to generate YouTube-like ids from numbers. Use it when you don't want to expose your database ids to the user.

ICSGenerator - The module can generate basic ICS calendar strings and files

ICSGenerator The module can generate basic ICS calendar strings and files. The module simply extends WireData. It has these properties and default val

The plugin generates posts/pages. Useful to generate millions of records in wp_posts table
The plugin generates posts/pages. Useful to generate millions of records in wp_posts table

KAGG Generator The plugin generates posts/pages. Useful to generate millions of records in wp_posts table. In WordPress development, sometimes it is n

Utilities to scan PHP code and generate class maps.

composer/class-map-generator Utilities to generate class maps and scan PHP code. Installation Install the latest version with: $ composer require comp

Releases(v0.1.1)
  • v0.1.1(Mar 27, 2022)

  • v0.1.0(Mar 27, 2022)

    laravel-round-robin

    Laravel package to generate sweepstakes using the Round Robin algorithm. Supports any number of teams, as long as they are greater than a minimum value specified in the configuration file. Built with Laravel Collections for better handling of arrays.

    Source code(tar.gz)
    Source code(zip)
Owner
TonyStore
Tecnologo en Informática - Desarrollador en Laravel 7 y Vue 2
TonyStore
Implementation of the Token Bucket algorithm in PHP.

Token Bucket This is a threadsafe implementation of the Token Bucket algorithm in PHP. You can use a token bucket to limit an usage rate for a resourc

null 477 Jan 7, 2023
Ip2region is a offline IP location library with accuracy rate of 99.9% and 0.0x millseconds searching performance. DB file is ONLY a few megabytes with all IP address stored. binding for Java,PHP,C,Python,Nodejs,Golang,C#,lua. Binary,B-tree,Memory searching algorithm

Ip2region是什么? ip2region - 准确率99.9%的离线IP地址定位库,0.0x毫秒级查询,ip2region.db数据库只有数MB,提供了java,php,c,python,nodejs,golang,c#等查询绑定和Binary,B树,内存三种查询算法。 Ip2region特性

Lion 12.6k Dec 30, 2022
XXTEA encryption algorithm library for PHP.

XXTEA for PHP Introduction XXTEA is a fast and secure encryption algorithm. This is a XXTEA library for PHP. It is different from the original XXTEA e

xxtea 107 Dec 8, 2022
PHP implementation of Rapid Automatic Keyword Exraction algorithm (RAKE) for extracting multi-word phrases from text

PHP implementation of Rapid Automatic Keyword Exraction algorithm (RAKE) for extracting multi-word phrases from text.

Assisted Mindfulness 7 Oct 19, 2022
This module adds a command to easily generate "modules" in Laravel and install them using composer.

Laravel Module Create This module adds a command to easily generate "modules" in Laravel and install them using composer Installation Simply install t

null 2 Feb 18, 2022
Optional package for Laravel to generate social share links.

Laravel Share Share links exist on almost every page in every project, creating the code for these share links over and over again can be a pain in th

Joren Van Hocht 466 Dec 21, 2022
Laravel package allows you to generate a YouTube player from a video link.

Youtube Frame Generator Laravel package allows you to generate an iframe tag with a video player depending on a youtube URL. 1 - Dependency The first

Syrian Open Source 17 Nov 2, 2022
#️⃣ Generate, Save, and Route Stripe-like Hash IDs for Laravel Eloquent Models

Using this package you can generate, save and, route Stripe-like Hash Ids for your Eloquent Models. Hash Ids are short, unique, and non-sequential, an

Yunus Emre Deligöz 88 Dec 27, 2022
Generate API documentation for humans from your Laravel codebase.✍

Scribe v3 is out now! Scribe helps you generate API documentation for humans from your Laravel/Lumen/Dingo codebase. See a live example at demo.scribe

Knuckles 1k Jan 9, 2023