how to join 2 table using ActiveDataProvider




public function actionIndex(){


    $query = Student::find()->orderBy('student_id DESC');

    $activeData = new ActiveDataProvider([

        'query' => $query,

        'pagination' => [

            'defaultPageSize' => 5,

        ]

    ]);


    return $activeData;


}


//from student models

public function getStudentJurusan()

{

     return $this->hasOne(Jurusan::className(), ['jurusan_id' => 'student_jurusan_id']);

}




//from jurusan models

public function getFalkutas()

{

     return $this->hasOne(Falkutas::className(), ['falkutas_id' => 'falkutas_id']);

}



this is what my public function actionIndex() return

<response>

<item>

<student_id>11</student_id>

<student_name>Irvan</student_name>

<student_npm>2015730008</student_npm>

<student_jurusan_id>8</student_jurusan_id>

<student_created_date>2016-09-05 12:41:04</student_created_date>

<student_picture>uploads/2015730008_Irvan.jpg</student_picture>

<student_content>Hi, i’am student</student_content>

</item>

</response>

insted of jurusan_id i want it to return jurusan_name and falkutas_name from jurusan table and falkutas table together with all of student.

what i want to get is

student_id

student_npm

jurusan_name

falkutas_name

student_created_date

student_picture

student_content

for all student_id, sry bad english. And i’am really new to yii

7077

Screenshot_21.jpg




    $query = Student::find()->with('studentJurusan.falktus')->orderBy('student_id DESC');



http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#lazy-eager-loading