SupervisorsModel.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Models;
  3. /**
  4. * 领航员/导师-模型
  5. */
  6. class SupervisorsModel extends BaseModel
  7. {
  8. // 设置数据表
  9. protected $table = 'supervisors';
  10. protected $appends = ['type_name','mobile_text'];
  11. // 头像
  12. public function getAvatarAttribute($value)
  13. {
  14. $value = $value ? get_image_url($value) : '';
  15. return $value;
  16. }
  17. /**
  18. * @return array
  19. */
  20. public function getmobileTextAttribute()
  21. {
  22. return $this->mobile? format_mobile($this->mobile):'';
  23. }
  24. // 类型
  25. public function getTypeNameAttribute($value)
  26. {
  27. $types = [1=>'专项导师',2=>'研究导师',3=>'发展导师'];
  28. return isset($types[$this->type])?$types[$this->type]:'--';
  29. }
  30. /**
  31. * 关联用户
  32. */
  33. public function member()
  34. {
  35. return $this->hasOne(MemberModel::class, 'id', 'user_id');
  36. }
  37. /**
  38. * 咨询记录
  39. */
  40. public function consults()
  41. {
  42. return $this->hasMany(SupervisorsConsultRecordsModel::class, 'source_id', 'id');
  43. }
  44. }