S
S
Sergey Beloventsev2016-10-18 13:48:06
Yii
Sergey Beloventsev, 2016-10-18 13:48:06

What is my mistake with deep nested relationship?

actually here is the code

$titleCat=FrontendSetup::findOne(['key_setup'=>'recomented']);
$recomented=Category::find()->where(['name'=>$titleCat->value])->with('goods','goods.images','goods.prise','goods.addfeilds','goods.ratingCountAggregation','goods.ratingSumAggregation')->all();

if(isset($recomented)) {
    foreach ($recomented as $rec){
        var_dump($rec->goods);
    }
}

gives such an error
common\models\Category has no relation named "images".

Caused by: Unknown Method – yii\base\UnknownMethodException
Calling unknown method: common\models\Category::getimages()
in /var/www/magaz.lc/vendor/yiisoft/yii2/base/Component.php at line 285

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2016-10-18
@Sergalas

at first glance, everything is in order in this code. Look for the problem in the relationships themselves

M
Maxim Timofeev, 2016-10-18
@webinar

To be honest, I'm not sure that yii can do this, I'm talking about goods.images
Perhaps you should first make a join for goods
You have an interesting idea, but I'm not sure if it's viable. Here, rather, in the Category model, you need to create links images, prize, etc. through communication goods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question