1
0

TrainClass.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class TrainClass extends Model
  5. {
  6. public function getCoverAttr($value)
  7. {
  8. return 'https://'.config('app.ali_oss_bindurl').'/'.$value;
  9. }
  10. public function doneLog()
  11. {
  12. return $this->hasMany('TrainDoneLog','class_id');
  13. }
  14. public function TrainSumup()
  15. {
  16. return $this->hasMany('TrainSumup','class_id');
  17. }
  18. public function getQrcodeAttr($value)
  19. {
  20. if ($value) {
  21. return 'https://'.config('app.ali_oss_bindurl').'/'.$value;
  22. }
  23. }
  24. public function company()
  25. {
  26. return $this->belongsTo('Company','root_id','root_id')->bind(['company_name']);
  27. }
  28. public function lecturer(){
  29. return $this->hasOne(Lecturer::class, 'id','lecturer_id');
  30. }
  31. public function getIntroduceAttr($value)
  32. {
  33. $value = $value ?: '';
  34. return $value;
  35. }
  36. public function getImgsAttr($value)
  37. {
  38. $value = $value ? explode(',',$value) : [];
  39. $url = config('app.ali_oss_bindurl');
  40. foreach ($value as $key => $value) {
  41. $value[$key] = 'https://'.$url.'/'.$value;
  42. }
  43. return $value;
  44. }
  45. }