Answer the question
In order to leave comments, you need to log in
What is the inappropriate relationship behavior in yii2?
There is this relationship:
public function getContractor()
{
return $this->hasOne(Contractors::class, ['id' => 'contractor']);
}
$model->contractor
int ID
, Answer the question
In order to leave comments, you need to log in
Attentively, but inattentively, they made the name of the properties or relationships.
You have a property in the database and in the model that matches the name of the connection. Therefore, you need to change it to contactor_id
or change the name of the connection. getContactorRelation
On request $model->contractor
, you get an id. First, the property is searched, and then the relationship.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question