Commit 321baf47 authored by 杨培's avatar 杨培

简化 Orders 中的 getCourseWithTeachers 方法

parent a5c649b2
...@@ -5,7 +5,7 @@ namespace common\models; ...@@ -5,7 +5,7 @@ namespace common\models;
use Yii; use Yii;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use yii\data\Pagination; use yii\data\Pagination;
use yii\redis\ActiveRecord; use yii\db\ActiveRecord;
/** /**
* This is the model class for table "orders". * This is the model class for table "orders".
...@@ -20,7 +20,7 @@ use yii\redis\ActiveRecord; ...@@ -20,7 +20,7 @@ use yii\redis\ActiveRecord;
* @property integer $created_at * @property integer $created_at
* @property integer $updated_at * @property integer $updated_at
*/ */
class Orders extends \yii\db\ActiveRecord class Orders extends ActiveRecord
{ {
//订单支付状体 //订单支付状体
...@@ -136,7 +136,7 @@ class Orders extends \yii\db\ActiveRecord ...@@ -136,7 +136,7 @@ class Orders extends \yii\db\ActiveRecord
/** /**
* 关联课程信息 * 关联课程信息
* @return $this * @return \yii\db\ActiveQuery
*/ */
public function getCourse() public function getCourse()
{ {
...@@ -145,11 +145,11 @@ class Orders extends \yii\db\ActiveRecord ...@@ -145,11 +145,11 @@ class Orders extends \yii\db\ActiveRecord
/** /**
* 关联课程信息(包括课程的讲师列表) * 关联课程信息(包括课程的讲师列表)
* @return $this * @return \yii\db\ActiveQuery
*/ */
public function getCourseWithTeachers() public function getCourseWithTeachers()
{ {
return $this->hasOne(Course::className(), ['id'=>'course_id'])->select('id,user_id,name,price,preview_pic')->with('teachers'); return $this->getCourse()->with('teachers');
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment