public static normalizeMap ( $array ) : array | ||
return | array |
public static function normalizeMap($array)
{
$nested = array();
foreach ((array) $array as $key => $value) {
if (is_numeric($key)) {
$nested[$value] = array();
} else {
$nested[$key] = $value;
}
}
return $nested;
}
/** * Eager load relationships to avoid the N+1 problem * @chainable */ public function includes($rels) { foreach (Relationship::normalizeMap($rels) as $alias => $nested) { $this->_includes[$alias] = new Relationships\Includer($this->_query, $this->_schema->relationship($alias), $nested); } return $this; }