Hello.
I can't figure it all out. How to create a linked model in Yii2.
The problem is that there are two models of ActiveRecord.
model1 contains fields [id, A, B] model2 contains fields [id, C, model1_id].
Those. model2 must enter id model1 in the [model1_id] field.
Is it correct to register in model2?
public function getCustomer() { return $this->hasOne(Model1::className(), ['model1_model_id' => 'id']); } I wrote this, but model1_id does not write to the database. What is the mistake, how to be properly done?
In the database tables do not link.
Thank you in advance. )