Commit 9b4235e2 authored by xiabin's avatar xiabin

overwrite teacher afterfind

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