public function getInstitute() { if ($this->course_id != NULL) { $institute_id = Course::find()->select(['institute_id'])->where(['id' => $this->course_id])->one()->institute_id; $institute = Institute::findOne(['id' => $institute_id]); return $institute; } }
/** * @return \yii\db\ActiveQuery */ public function getCourses() { return $this->hasMany(Course::className(), ['institute_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getCourses() { return $this->hasMany(Course::className(), ['id' => 'course_id'])->viaTable('user_has_course', ['user_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getCourse() { return $this->hasOne(Course::className(), ['id' => 'course_id']); }