1
0

TrainCourse.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. use app\model\TrainType;
  6. class TrainCourse extends Model
  7. {
  8. use SoftDelete;
  9. protected $deleteTime = 'delete_time';
  10. protected $defaultSoftDelete = 0;
  11. public function getTypeIdAttr($value , $data)
  12. {
  13. if (empty($value)) return $value;
  14. $name = TrainType::where(['id'=>$value , 'root_id'=>$data['root_id']])->value('type');
  15. return $name;
  16. }
  17. public function getFileAttr($value)
  18. {
  19. if (empty($value)) return $value;
  20. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  21. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  22. return $url;
  23. }
  24. public function getVideoImgAttr($value)
  25. {
  26. if (empty($value)) return $value;
  27. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  28. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  29. return $url;
  30. }
  31. public function trainCourseView(){
  32. return $this->hasMany(TrainCourseView::class, 'con_id', 'id');
  33. }
  34. }