chrgriffin / collection-macro-thanos
Laravel 集合宏:随机删除集合中一半的项目。
v1.0.0
2020-02-28 21:52 UTC
Requires
- php: ^7.1.3
Requires (Dev)
- orchestra/testbench: ^4.0
- php-coveralls/php-coveralls: ^2.2
This package is auto-updated.
Last update: 2024-08-29 05:01:03 UTC
README
Laravel 集合宏:Thanos
这个 Laravel 集合宏将随机删除集合中一半的项目。
安装
使用 composer 在您的 Laravel 项目中安装
composer install chrgriffin/collection-macro-thanos
如果您的 Laravel 版本支持自动发现(版本 5.5 及以上),那么就完成了!
对于旧版本的 Laravel,您需要编辑您的 config/app.php
文件,将服务提供者在 providers 数组中包含进来
return [ // ... 'providers' => [ // ... CollectionMacroThanos\ServiceProvider::class ] ];
使用
现在您应该能够在任何集合上链式调用 ->thanos()
以随机删除集合中一半的项目。
$collection = collect([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) ->thanos(); // 1, 3, 4, 6, 8