VrView.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class VrView extends Model
  9. {
  10. /**
  11. * 关联VR视图组
  12. */
  13. public function group()
  14. {
  15. return $this->belongsTo(VrGroup::class, 'vr_group_id');
  16. }
  17. /**
  18. * 拼接
  19. */
  20. public function getPicPathAttr($value)
  21. {
  22. if (empty($value)) return $value;
  23. $ali_oss_bindurl = config('app.vr_ali_oss_bindurl');
  24. $url = 'https://' . $ali_oss_bindurl . '/' . $value;
  25. return $url;
  26. }
  27. /**
  28. * 处理
  29. */
  30. public function setPicPathAttr($value){
  31. $ali_oss_bindurl = config('app.vr_ali_oss_bindurl');
  32. $url = 'https://' . $ali_oss_bindurl . '/';
  33. return str_replace($url, '', $value);
  34. }
  35. /**
  36. * 拼接
  37. */
  38. // public function getVrPathAttr($value)
  39. // {
  40. // if (empty($value)) return $value;
  41. // // $ali_oss_bindurl = config('app.ali_oss_bindurl');
  42. // $ali_oss_bindurl = 'vr.oss.xueque.net/';
  43. // $url = 'https://' . $ali_oss_bindurl . $value;
  44. // return $url;
  45. // }
  46. /**
  47. * 处理
  48. */
  49. public function setVrPathAttr($value){
  50. $ali_oss_bindurl = config('app.vr_ali_oss_bindurl');
  51. $url = 'https://' . $ali_oss_bindurl . '/';
  52. return str_replace($url, '', $value);
  53. }
  54. /**
  55. * 关联视图
  56. */
  57. public function hotspot()
  58. {
  59. return $this->hasMany(VrHotspot::class, 'view_id');
  60. }
  61. }