I
I
Ilya Beloborodov2017-01-09 20:02:46
Yii
Ilya Beloborodov, 2017-01-09 20:02:46

How to link models through a linked table?


You need to select an article, and with it all its authors (there can be > 1)
65ae79e44f1b43a685798741e892a5dd.png
. Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Beloborodov, 2017-01-09
@kowap

with grief on the floor

public function getAuthors(){
        return $this->hasMany(\app\models\Profile::className(), ['user_id'=>'id_author'])
            ->viaTable(\app\models\MaterialJoinAuthor::tableName(),['id_material' => 'id_material']);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question