List Util
App\Shared\Services\ListUtil
Method | Description | Type | Parameters | Return |
---|---|---|---|---|
__construct | public | |||
getInput | public | array The input array | ||
getOutput | public | array The output array | ||
filter | Filters the list, based on a set of key => value arguments against each object Default empty array all elements from the array must match 'OR' means only one element needs to match 'NOT' means no elements may match Default 'AND' |
public | array $args Optional An array of key => value arguments to match string $operator Optional The logical operation to perform 'AND' means |
array Array of found values |
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 Default null corresponding to $indexKey If $indexKey is null, array keys from the original$list will be preserved in the results |
public | int|string $field Field from the object to place instead of the entire object int|string|null $indexKey Optional Field from the object to use as keys for the new array |
array Array of found values If $indexKey is set, an array of found values with keys |
sort | Sorts the list, based on one or more orderby arguments of multiple orderby fields as $orderby => $order is a string |
public | array|string $orderby Optional Either the field name to order by or an array string $order Optional Either 'ASC' or 'DESC' Only used if $orderby bool $preserverKeys Optional Whether to preserve keys Default false |
array The sorted array |
sortCallback | Callback to sort the list by specific fields see ListUtil::sort() |
private | object|array $a One object to compare object|array $b The other object to compare |
int 0 if both objects equal -1 if second object should come first, 1 otherwise |