chrisrhymes / extra-collect
A Laravel package containing a collection of collections
v0.1
2022-02-26 13:05 UTC
Requires (Dev)
- orchestra/testbench: ^5.0|^6.0|^7.0
- phpunit/phpunit: ^9.4
This package is auto-updated.
Last update: 2024-11-26 19:42:57 UTC
README
Some extra Laravel collection methods.
composer require chrisrhymes/extra-collect
Contents
Collection Methods
Prefix
collect(['a', 'b', 'c'])->prefix('test'); // ['testa', 'testb', 'testc'] collect([['name' => 'a'], ['name' => 'b'], ['name' => 'c']])->prefix('test', 'name'); // [['name' => 'testa'], ['name' => 'testb'], ['name' => 'testc']]
Suffix
collect(['a', 'b', 'c'])->suffix('test'); // ['atest', 'btest', 'ctest'] collect([['name' => 'a'], ['name' => 'b'], ['name' => 'c']])->suffix('test', 'name'); // [['name' => 'atest'], ['name' => 'btest'], ['name' => 'ctest']]
Double Quote
collect(['a', 'b', 'c'])->doubleQuote(); // ['"a"', '"b"', '"c"'] collect([['name' => 'a'], ['name' => 'b'], ['name' => 'c']])->doubleQuote('name'); // [['name' => '"a"'], ['name' => '"b"'], ['name' => '"c"']]
Testing
composer test