Answer the question
In order to leave comments, you need to log in
How to get array via hasMany relationship?
There are 3 tables users, companies, user role in the company, companies
Accordingly, there are connections:
users->hasMany user role in the company
user role in the company -> hasOne company
It is necessary to select companies for a specific user.
I can't figure out how to do it right.
Answer the question
In order to leave comments, you need to log in
And the casket just opened
$array = $this->hasMany(Имя первой связиe::className(), ['user_id' => 'id'])->all();
return ArrayHelper::getColumn($array,'имя второй связи');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question