- Full name:
\App\Shared\Services\ListUtil - This class is marked as final and can't be subclassed
- This class is a Final class
Properties
input
output
Methods
__construct
Parameters:
| Parameter | Type | Description |
|---|---|---|
$input |
array |
filter
Filters the list, based on a set of key => value arguments.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$args |
array | Optional. An array of key => value arguments to match |
| against each object. Default empty array. | ||
$operator |
string | Optional. The logical operation to perform. 'AND' means |
| all elements from the array must match. 'OR' means only | ||
| one element needs to match. 'NOT' means no elements may | ||
| match. Default 'AND'. |
Return Value:
Array of found values.
Throws:
pluck
Plucks a certain field out of each object in the list.
This has the same functionality and prototype of array_column() but also supports objects.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$field |
int|string | Field from the object to place instead of the entire object |
$indexKey |
int|string|null | Optional. Field from the object to use as keys for the new array. |
| Default null. |
Return Value:
Array of found values. If $indexKey is set, an array of found values with keys
corresponding to $indexKey. If $indexKey is null, array keys from the original
$list will be preserved in the results.
sort
Sorts the list, based on one or more orderby arguments.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$orderby |
array|string | Optional. Either the field name to order by or an array |
| of multiple orderby fields as $orderby => $order. | ||
$order |
string | Optional. Either 'ASC' or 'DESC'. Only used if $orderby |
| is a string. | ||
$preserveKeys |
bool | Optional. Whether to preserve keys. Default false. |
Return Value:
The sorted array.
reset
Reset output back to original input.
all
Return the current working list.
compareItems
Parameters:
| Parameter | Type | Description |
|---|---|---|
$a |
mixed | |
$b |
mixed | |
$orderBy |
array |
compareValues
Parameters:
| Parameter | Type | Description |
|---|---|---|
$a |
mixed | |
$b |
mixed |
value
Parameters:
| Parameter | Type | Description |
|---|---|---|
$item |
mixed | |
$field |
int|string |
isValidArrayKey
Parameters:
| Parameter | Type | Description |
|---|---|---|
$value |
mixed |