| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\Models;
- /**
- * 领航员/导师-模型
- */
- class SupervisorsModel extends BaseModel
- {
- // 设置数据表
- protected $table = 'supervisors';
- protected $appends = ['type_name','mobile_text'];
- // 头像
- public function getAvatarAttribute($value)
- {
- $value = $value ? get_image_url($value) : '';
- return $value;
- }
- /**
- * @return array
- */
- public function getmobileTextAttribute()
- {
- return $this->mobile? format_mobile($this->mobile):'';
- }
- // 类型
- public function getTypeNameAttribute($value)
- {
- $types = [1=>'专项导师',2=>'研究导师',3=>'发展导师'];
- return isset($types[$this->type])?$types[$this->type]:'--';
- }
- /**
- * 关联用户
- */
- public function member()
- {
- return $this->hasOne(MemberModel::class, 'id', 'user_id');
- }
- /**
- * 咨询记录
- */
- public function consults()
- {
- return $this->hasMany(SupervisorsConsultRecordsModel::class, 'source_id', 'id');
- }
- }
|