marcelotk15 / round-robin
适用于 Laravel 5.8+ 的 RoundRobin。
0.1.0
2017-02-18 01:48 UTC
Requires
- php: >=5.6.4
Requires (Dev)
- phpunit/phpunit: 5.5.*
This package is auto-updated.
Last update: 2024-08-29 03:58:12 UTC
README
Round-Robin 是一种通过轮询(rr)技术创建排程的简单方法。我为这个项目使用了 mnito 的基础代码。查看这里: https://github.com/mnito/round-robin
安装
- 为了安装 Laravel Round-Robin,只需将以下内容添加到您的 composer.json 中。然后运行
composer update
"marcelotk15/round-robin": "0.1.*"
或者运行 composer require marcelotk15/round-robin
- 打开您的
config/app.php并将以下内容添加到providers数组中
Laravel\RoundRobin\RoundRobinServiceProvider::class,
- 打开您的
config/app.php并将以下内容添加到facades数组中
'RoundRobin' => Laravel\RoundRobin\RoundRobinFacade::class,
控制器和其他
use Laravel\RoundRobin\RoundRobin;
使用(示例)
设置(无 Facade)
$teams = ['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 = ['Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid']; $schedule = RoundRobin::from($teams)->make();
使用 $shuffle 布尔参数来避免随机打乱队伍,生成排程
$teams = ['Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid']; $schedule = RoundRobin::from($teams)->doNotShuffle()->make();
使用 $seed 整数参数来使用您自己的种子进行预定打乱
$teams = ['Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid']; $schedule = RoundRobin::from($teams)->shuffle(15)->make();
如果您想要双轮询
$teams = ['Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid']; $schedule = RoundRobin::from($teams)->doubleRoundRobin()->make();
如果您想要获取 排程 对象
$teams = ['Arsenal', 'Atlético de Madrid', 'Borussia', 'Barcelona','Liverpool', 'Bayer 04', 'Real Madrid']; $schedule = RoundRobin::from($teams)->makeSchedule();
许可证
Laravel Round-Robin 是免费软件,根据 MIT 许可证的条款分发。