boraguler/round-robin

RoundRobin for Laravel 5.8+.

v1.0.3 2020-04-02 18:22 UTC

This package is auto-updated.

Last update: 2024-08-29 05:43:14 UTC


README

Latest Stable Version Total Downloads Monthly Downloads Latest Unstable Version License

BoraGuler\Round-Robin is an easy way to create schedule with round-robin(rr) technique.

Installation

  1. In order to install BoraGuler\Round-Robin, just add the following to your composer.json. Then run composer update:
"boraguler/round-robin": "1.0.*"

or run composer require boraguler/round-robin

  1. Open your config/app.php and add the following to the providers array:
BoraGuler\RoundRobin\RoundRobinServiceProvider::class,
  1. Open your config/app.php and add the following to the facades array:
'RoundRobin' => boraguler\RoundRobin\RoundRobinFacade::class,

Controllers and etc

use BoraGuler\RoundRobin\RoundRobin;

Using (Examples)

Setuping (without Facade):

$teams = ['Galatasaray', 'Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid'];
$schedule = new RoundRobin($teams)->make();
// or with 'from' static method
$schedule = RoundRobin::from($teams)->make();

With a facade:

$teams = ['Galatasaray', 'Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid'];
$schedule = RoundRobin::from($teams)->make();

Generate a schedule without randomly shuffling the teams using the $shuffle boolean parameter:

$teams = ['Galatasaray', 'Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid'];
$schedule = RoundRobin::from($teams)->doNotShuffle()->make();

Use your own seed with the $seed integer parameter for predetermined shuffling:

$teams = ['Galatasaray', 'Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid'];
$schedule = RoundRobin::from($teams)->shuffle(15)->make();

If you want to pre-define round number (default = 1):

$teams = ['Galatasaray', 'Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid'];
$schedule = RoundRobin::from($teams)->rounds(3)->make();

If you want a double Round-robin:

$teams = ['Galatasaray', 'Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid'];
$schedule = RoundRobin::from($teams)->doubleRoundRobin()->make();

If you want a get a Schedule Object:

$teams = ['Galatasaray', 'Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid'];
$schedule = RoundRobin::from($teams)->makeSchedule();

License

BoraGuler Round-Robin is free software distributed under the terms of the MIT license.