M
M
Michael2018-11-26 13:37:18
Yii
Michael, 2018-11-26 13:37:18

How to properly link models on view?

Good afternoon. Can you tell me how to properly link models in yii2?
There is a simple model that has another model attached to it.
Store - id, name , id_city
City - id, name
What is the correct way to get this link, call it in the controller?
type

Магазин::find()->joinWith('Город')->where('ид'=>$id)->one();

or use afterFind() ?
If afterFind, please tell me how to do it right?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question