boraguler/round-robin

适用于 Laravel 5.8+ 的 RoundRobin。

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

This package is auto-updated.

Last update: 2024-09-29 05:49:28 UTC


README

Latest Stable Version Total Downloads Monthly Downloads Latest Unstable Version License

BoraGuler\Round-Robin 是一种使用循环轮询(rr)技术创建计划的简单方法。

安装

  1. 为了安装 BoraGuler\Round-Robin,只需将以下内容添加到您的 composer.json 中。然后运行 composer update
"boraguler/round-robin": "1.0.*"

或运行 composer require boraguler/round-robin

  1. 打开您的 config/app.php 文件,并将以下内容添加到 providers 数组中
BoraGuler\RoundRobin\RoundRobinServiceProvider::class,
  1. 打开您的 config/app.php 文件,并将以下内容添加到 facades 数组中
'RoundRobin' => boraguler\RoundRobin\RoundRobinFacade::class,

控制器等

use BoraGuler\RoundRobin\RoundRobin;

使用(示例)

设置(无 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();

使用 Facade

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

使用 $shuffle 布尔参数生成不带随机洗牌的队伍计划

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

使用 $seed 整数参数使用自己的种子进行预定洗牌

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

如果您想预定义轮次数(默认 = 1)

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

如果您想进行双重循环轮询

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

如果您想获取一个 计划 对象

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

许可证

BoraGuler Round-Robin 是在 MIT 许可证条款下分发的免费软件。