chrgriffin / collection-macro-thanos
Laravel Collection macro: randomly delete half of the items in a Collection.
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-10-29 05:29:12 UTC
README
Laravel Collection Macro: Thanos
This macro for Laravel Collections will randomly delete half the items in a collection.
Installation
Install in your Laravel project via composer:
composer install chrgriffin/collection-macro-thanos
If your version of Laravel supports auto-discovery (versions 5.5 and up), that's it!
For older versions of Laravel, you will need to edit your config/app.php
file to include the service provider in your providers array:
return [ // ... 'providers' => [ // ... CollectionMacroThanos\ServiceProvider::class ] ];
Usage
You should now be able to chain ->thanos()
onto any collections to randomly delete half the items in the collection.
$collection = collect([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) ->thanos(); // 1, 3, 4, 6, 8