ConstructionRecord.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class ConstructionRecord extends Model
  5. {
  6. public function getImgAttr($value)
  7. {
  8. if (empty($value)) return $value;
  9. $arr = explode(',', $value);
  10. $domain = config('app.ali_oss_bindurl');
  11. foreach ($arr as &$item) {
  12. $item = 'https://' . $domain . '/' . $item;
  13. }
  14. return $arr;
  15. }
  16. public function setImgAttr($value)
  17. {
  18. $domain = config('app.ali_oss_bindurl');
  19. $search = 'https://' . $domain . '/';
  20. return str_replace($search, '', $value);
  21. }
  22. public function getVideoAttr($value){
  23. if (empty($value)) return $value;
  24. $domain = config('app.ali_oss_bindurl');
  25. $url = 'https://' . $domain . '/' . $value;
  26. return $url;
  27. }
  28. public function setVideoAttr($value)
  29. {
  30. $domain = config('app.ali_oss_bindurl');
  31. $search = 'https://' . $domain . '/';
  32. return str_replace($search, '', $value);
  33. }
  34. public function getVideoCoverAttr($value){
  35. if (empty($value)) return $value;
  36. $domain = config('app.ali_oss_bindurl');
  37. $url = 'https://' . $domain . '/' . $value;
  38. return $url;
  39. }
  40. public function setVideoCoverAttr($value)
  41. {
  42. $domain = config('app.ali_oss_bindurl');
  43. $search = 'https://' . $domain . '/';
  44. return str_replace($search, '', $value);
  45. }
  46. public function step()
  47. {
  48. return $this->belongsTo(ConstructionStep::class, 'step_id');
  49. }
  50. }