Добрый день, есть модель Images
Array
(
[0] => common\modules\shop\models\backend\Image Object
(
[file] =>
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 58
[product_id] => 1
[name] => 1604996735_EJmFO5JdsY.jpg
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 58
[product_id] => 1
[name] => 1604996735_EJmFO5JdsY.jpg
)
[_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] => common\modules\shop\models\backend\Image Object
(
[file] =>
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 59
[product_id] => 1
[name] => 1604996735_XMoGwYlJZe.jpg
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 59
[product_id] => 1
[name] => 1604996735_XMoGwYlJZe.jpg
)
[_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
(
)
)
)
пытаюсь получить поле 'name' через $model->images->name выдает ошибку - Trying to get property 'name' of non-object
Если через foreach пропустить $model->images, то внутри цикла конструкция $image->name работает,
так вот вопрос как правильно получить имя изображения не прибегая к циклам