private indexBuckets ( array $buckets, $indexBy ) : array | ||
$buckets | array | |
Résultat | array |
private function indexBuckets($buckets, $indexBy)
{
$result = [];
foreach ($buckets as $key => $models) {
$result[$key] = [];
foreach ($models as $model) {
$index = is_string($indexBy) ? $model[$indexBy] : call_user_func($indexBy, $model);
$result[$key][$index] = $model;
}
}
return $result;
}