Commit 9b4235e2 authored by xiabin's avatar xiabin

overwrite teacher afterfind

parent d53fd0fe
......@@ -32,7 +32,8 @@ class Teacher extends ActiveRecord
return 'teacher';
}
public function formName() {
public function formName()
{
return '';
}
......@@ -45,13 +46,23 @@ class Teacher extends ActiveRecord
[['name', 'class_id'], 'required'],
[['user_id', 'created_at', 'updated_at'], 'integer'],
[['intro'], 'string'],
[['intro'], 'default', 'value'=>''],
[['name'], 'string', 'min'=>2, 'max' => 64],
[['intro'], 'default', 'value' => ''],
[['name'], 'string', 'min' => 2, 'max' => 64],
[['avatar'], 'string', 'max' => 100],
[['avatar'], 'default', 'value' => ''],
];
}
/**
* @inheritdoc
*/
public function afterFind()
{
parent::afterFind(); // TODO: Change the autogenerated stub
$this->avatar = User::getAvatarUrl($this->avatar);
}
/**
* @inheritdoc
*/
......@@ -101,7 +112,7 @@ class Teacher extends ActiveRecord
//return $obj->select('t.id,t.user_id,t.name,t.avatar')->join('LEFT JOIN', $teacherTable.' t', 't.id=c.teacher_id')
// ->from(self::tableName().' c')->where(['c.class_id'=>$classId])->asArray()->all();
return $obj->select('id,user_id,name,avatar')->where(['class_id'=>$classId])->asArray()->all();
return $obj->select('id,user_id,name,avatar')->where(['class_id' => $classId])->asArray()->all();
}
/**
......@@ -113,7 +124,7 @@ class Teacher extends ActiveRecord
*/
public static function filterOwnTeacherIds($classId, $teacherIds)
{
$result = self::find()->select('id')->where(['class_id'=>$classId, 'id'=>$teacherIds])->all();
$result = self::find()->select('id')->where(['class_id' => $classId, 'id' => $teacherIds])->all();
$ids = [];
......@@ -132,10 +143,10 @@ class Teacher extends ActiveRecord
* @param int $pageSize
* @return array
*/
public static function fetchTeachers($classId, $page=0, $pageSize=10)
public static function fetchTeachers($classId, $page = 0, $pageSize = 10)
{
$query = self::find()->select('id,user_id,name,avatar,intro')
->where(['class_id'=>$classId])->orderBy(['id'=>SORT_DESC])->asArray();
->where(['class_id' => $classId])->orderBy(['id' => SORT_DESC])->asArray();
$provider = new ActiveDataProvider([
'query' => $query,
......
......@@ -19,7 +19,7 @@
<div class="video-detail-info">
<div v-for="(index,item) in coursewareInfo.teachers" class="video-teacher">
<a data-toggle="modal" data-target="{{{'#teacherInfo'+index}}}"><img
:src="getFullPic(item.avatar)"></a>
:src="item.avatar"></a>
<p><a href="javascript:;" data-toggle="modal" data-target="#myModal2">{{item.name}}</a></p>
</div>
<div class="video-sm-info pull-right">
......@@ -100,7 +100,7 @@
</div>
<div class="modal-body">
<div class="teacher-info text-center">
<img :src="getFullPic(item.avatar)">
<img :src="item.avatar">
<h3>{{item.name}}</h3>
<p class="teacher-detail">{{{item.intro}}}</p>
</div>
......
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