ifresh / collection-macros
此包最新版本(v1.0.2)没有可用的许可证信息。
收集了各种有用的Laravel集合类扩展
v1.0.2
2022-03-21 10:48 UTC
Requires
- php: ^8.0
Requires (Dev)
- orchestra/testbench: ^7.1
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-21 16:46:10 UTC
README
iFresh Laravel 集合辅助函数
描述
此包包含一系列(愚蠢的)Laravel 集合宏。你可能不需要它们。或者也许你需要,我不知道,你知道你的需要。
提供的方法
数字
针对仅包含数字的集合的宏方法。
greaterThan
返回一个包含大于提供的最小值的数字集合。不包含。
// [3, 4] collect([1, 2, 3, 4])->greaterThan(2);
lessThan
返回一个包含小于提供的最大值的数字集合。不包含。
// [1, 2] collect([1, 2, 3, 4])->lessThan(3);
multiply
返回将集合中的所有数字相乘得到的结果。
// 6 (1 * 2 * 3) collect([1, 2, 3])->multiply();
字符串
针对仅包含字符串的集合的宏方法。
toLower
将集合中的所有字符串转换为小写。
// ['a', 'b', 'c'] collect(['A', 'B', 'C'])->toLower();
toUpper
将集合中的所有字符串转换为大写。
// ['A', 'B', 'C'] collect(['a', 'b', 'c'])->toUpper();