How Can I Get Table Via Hasmany In Yii2?

Hi all!

I have a tables:


(id, name, surname)



(u_id1, u_id2).

In model action:

(Not working)

return $this->hasMany(User::className(), [‘id’ => ‘u_id1’, ‘id’ => ‘u_id2’])

        ->viaTable('UserContacts', ['id' => 'u_id1', 'id' => 'u_id2']); 

Prompt how can I get a table with users through viaTable ()?

Ie I need to associate users table UserContacts to u_id1=id (id user from table User),u_id2=id (id user from table User).

And then get all the data.

        return $this->hasMany(User::className(), ['id' => 'u_id2'])->viaTable(UserContact::tableName(), ['u_id1' => 'id'],

            function($query) {

            $query->where(['status' => 0]);