Answer the question
In order to leave comments, you need to log in
How to find out that connected models are connected?
Tell me how to find out that connected models are correctly connected via hasMany. For example: if there are user and product tables.
there is a connection between them
public function getTovar(){
return $this->hasMany(Tovar::className(), ['id' => 'userID']);
}
$model=User::find()->all();
$model->tovar.
Answer the question
In order to leave comments, you need to log in
Good morning.
What do you mean?
If you look in the documentation , you will find the following methods:
1) getRelatedRecords() - will return all model relationships
2) getRelation() - will return data for a single relationship, in your case$model->getRelation('tovar')
As usual, for example through print_r($model)
orprint_r($model->attributes)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question