Есть объект items, внутри которого объекты. У дочернего объекта имеющего свойство id = 2 нужно поменять свойство name.
Как это можно сделать красиво? Я могу конечно объект items перебрать, и по банальному сравнению id == 2 изменять свойства, но это же костыль.
Объект для примера вот:
spoiler
Array
(
[0] => app\models\Platform Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 5
[name] => first
[commission] => 4
[date] =>
[active] =>
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 5
[name] => first
[commission] => 4
[date] =>
[active] =>
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
)
[_relationsDependencies:yii\db\BaseActiveRecord:private] => Array
(
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_eventWildcards:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
)
[1] => app\models\Platform Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 7
[name] => second
[commission] => 42
[date] =>
[active] =>
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 7
[name] => second
[commission] => 42
[date] =>
[active] =>
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
)
[_relationsDependencies:yii\db\BaseActiveRecord:private] => Array
(
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_eventWildcards:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
)
)