ifresh/collection-macros

There is no license information available for the latest version (v1.0.2) of this package.

A collection of various useful additions to the Laravel collection class

v1.0.2 2022-03-21 10:48 UTC

This package is auto-updated.

Last update: 2024-04-21 15:40:24 UTC


README

68747470733a2f2f6966726573682e6e6c2f6170702f7468656d65732f6966726573682f646973742f696d616765732f6c6f676f2e737667

iFresh Laravel Collection helpers

Description

This package contains a set of (silly) Laravel Collection macros. You probably won't need them. Or maybe you do, I don't know, you do you.

68747470733a2f2f707265766965772e726564642e69742f6b6c6236726c68396c6d3837312e6a70673f6175746f3d7765627026733d65333436653537636361656337663762363936326230313965363366643161613062326433653635

Provided methods

Numbers

Macro methods that are intended for working with collections that contain only numbers.

greaterThan

Returns a set of numbers that are larger than the provided minimum value. Non-inclusive.

// [3, 4]
collect([1, 2, 3, 4])->greaterThan(2); 

lessThan

Returns a set of numbers that are smaller than the provided maximum value. Non-inclusive.

// [1, 2]
collect([1, 2, 3, 4])->lessThan(3); 

multiply

Returns the result that is gotten by multiplying all the numbers in the collection together.

// 6 (1 * 2 * 3)
collect([1, 2, 3])->multiply();

Strings

Macro methods that are intended for working with collections that contain only strings.

toLower

Convert all the strings in the collection to their lowercase value.

// ['a', 'b', 'c']
collect(['A', 'B', 'C'])->toLower();

toUpper

Convert all the strings in the collection to their uppercase value.

// ['A', 'B', 'C']
collect(['a', 'b', 'c'])->toUpper();