Answer the question
In order to leave comments, you need to log in
Outputting data from two tables into one gridview yii2?
There are two tables without keys. For each created a model (Order and Manager). For Order, I created a crud gridview and wrote the following in its model
public function getManager(){
return $this->hasMany(Manager::className(), ['order_managerId' => 'manager_id']);
}
where order_managerId is a column from the table in which this function is written, and manager_id is a column from the second table. I want to display manager_firstName instead of id from the second table. The question is, am I doing the right thing? In view, I tried several options, while it gives an error.
Answer the question
In order to leave comments, you need to log in
UPD. Changed to public function getManager(){
return $this->hasOne(Manager::className(), ['manager_id' => 'order_managerId']);
} Everything worked
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question