chrisrhymes / extra-collect
包含一系列集合的 Laravel 扩展包
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-09-26 19:17:56 UTC
README
一些额外的 Laravel 集合方法。
composer require chrisrhymes/extra-collect
内容
集合方法
前缀
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']]
后缀
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']]
双引号
collect(['a', 'b', 'c'])->doubleQuote(); // ['"a"', '"b"', '"c"'] collect([['name' => 'a'], ['name' => 'b'], ['name' => 'c']])->doubleQuote('name'); // [['name' => '"a"'], ['name' => '"b"'], ['name' => '"c"']]
测试
composer test