PHP code example of tonystore / laravel-round-robin

1. Go to this page and download the library: Download tonystore/laravel-round-robin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tonystore / laravel-round-robin example snippets


['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"
    }
  ],
]

$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();

$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();

$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);

$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);

$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();

$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();

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

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

$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();

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

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


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',
]