Lecturer.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class Lecturer extends Model
  5. {
  6. public function company(){
  7. return $this->hasOne(LecturerCompany::class, 'id','lecturer_company_id');
  8. }
  9. /**
  10. * 图片拼接
  11. */
  12. public function getPhotoAttr($value)
  13. {
  14. if (empty($value)) return $value;
  15. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  16. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  17. return $url;
  18. }
  19. /**
  20. * 图片拼接
  21. */
  22. public function getPosterAttr($value)
  23. {
  24. if (empty($value)) return $value;
  25. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  26. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  27. return $url;
  28. }
  29. /**
  30. * 图片拼接
  31. */
  32. public function getAddtimeAttr($value)
  33. {
  34. if (empty($value)) return $value;
  35. $value = date('Y-m-d',$value);
  36. return $value;
  37. }
  38. public function setPosterAttr($value){
  39. $domain = config('app.ali_oss_bindurl');
  40. $search = 'https://'.$domain.'/';
  41. return str_replace($search, '', $value);
  42. }
  43. public function setPhotoAttr($value){
  44. $domain = config('app.ali_oss_bindurl');
  45. $search = 'https://'.$domain.'/';
  46. return str_replace($search, '', $value);
  47. }
  48. //讲师课程
  49. public function train(){
  50. return $this->hasMany(TrainClass::class,'lecturer_id','id');
  51. }
  52. }