DesignerCollectionWorks.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. use xiaohongwu\Vr;
  5. class DesignerCollectionWorks extends Model
  6. {
  7. public function getDescAttr($value)
  8. {
  9. if (empty($value)) return $value;
  10. $domain = config('app.ali_oss_bindurl');
  11. $item = 'https://' . $domain . '/';
  12. $list = explode(',',$value);
  13. foreach($list as $v){
  14. $arr[] = $item.$v;
  15. }
  16. return $arr;
  17. }
  18. public function getCoverImgAttr($value)
  19. {
  20. if (empty($value)) return $value;
  21. $domain = config('app.ali_oss_bindurl');
  22. $item = 'https://' . $domain . '/';
  23. $value = $item.$value;
  24. return $value;
  25. }
  26. public function getVrCaseAttr($value)
  27. {
  28. if (empty($value)) return $value;
  29. $list = explode(',',$value);
  30. foreach($list as $v){
  31. $new[] = ['vr_link'=>$v,'vr_img'=>getFirstImg($v)];
  32. }
  33. return $new;
  34. }
  35. public function setCoverImgAttr($value)
  36. {
  37. if (empty($value)) return $value;
  38. $domain = config('app.ali_oss_bindurl');
  39. $item = 'https://' . $domain . '/';
  40. $value = str_replace($item,'',$value);
  41. return $value;
  42. }
  43. public function setDescAttr($value)
  44. {
  45. if (empty($value)) return $value;
  46. $domain = config('app.ali_oss_bindurl');
  47. $item = 'https://' . $domain . '/';
  48. $list = explode(',',$value);
  49. $str = null;
  50. foreach($list as $v){
  51. $str.= str_replace($item,'',$v).',';
  52. }
  53. return trim($str,',');
  54. }
  55. public function decostyle()
  56. {
  57. return $this->hasOne(Decostyle::class, 'id','style_id')->bind(['style_name'=>'name']);
  58. }
  59. public function housetype()
  60. {
  61. return $this->hasOne(Housetype::class, 'id','housetype_id')->bind(['housetype_name'=>'name']);
  62. }
  63. }