можно попробовать обойти до как нибудь
$equipment = Type::find()->indexBy('id')->asArray()->all();
$equipment = array_map(function ($row) use ($equipment) {
$row['parent_name'] = isset($equipment[$row['parent_id']]) ? $equipment[$row['parent_id']]['name'] : null;
return $row;
}, $equipment);
$equipment = array_filter($equipment, function ($row) {
return $row['parent_name'];
});
$result = ArrayHelper::map($equipment, 'id', 'name', 'parent_name');
up:
или лучше попробовать
$equipment = Type::find()->indexBy('id')->asArray()->all();
$equipment = array_map(function ($row) use ($equipment) {
$row['parent_name'] = isset($equipment[$row['parent_id']]) ? $equipment[$row['parent_id']]['name'] : $row['parent_id'];
return $row;
}, $equipment);
$result = ArrayHelper::map($equipment, 'id', 'name', 'parent_name');
if(isset($result[0])) {
unset($result[0]);
}