/** * 返回章节的数组 * @return array|\yii\db\ActiveRecord[] */ public function getChapters() { return $this->hasMany(Chapter::className(), ['course_id' => 'id'])->orderBy(['sort_order' => SORT_ASC]); }
/** * @return \yii\db\ActiveQuery */ public function getChapter() { return $this->hasOne(Chapter::className(), ['id' => 'chapter_id']); }