BuildingHousetype.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class BuildingHousetype extends Model
  5. {
  6. public function materialCase(){
  7. return $this->hasMany(BuildingMaterialCase::class, 'housetype_id', 'id');
  8. }
  9. public function devcase(){
  10. return $this->hasMany(BuildingDevelopCase::class, 'housetype_id', 'id');
  11. }
  12. public function getHouseImgAttr($value)
  13. {
  14. if (empty($value)) return [];
  15. $arr = explode(',', $value);
  16. $ali_oss_bindurl = config('app.ali_oss_bindurl');
  17. foreach($arr as &$item){
  18. $item = 'https://'.$ali_oss_bindurl.'/'.$item;
  19. }
  20. return $arr;
  21. }
  22. public function setHouseImgAttr($value){
  23. $domain = config('app.ali_oss_bindurl');
  24. $search = 'https://'.$domain.'/';
  25. return str_replace($search, '', $value);
  26. }
  27. public function getOrientationAttr($value)
  28. {
  29. if (empty($value)) return '朝向暂无';
  30. $xin = str_replace(',','|',$value);
  31. return $xin;
  32. }
  33. public function getImgContentAttr($value){
  34. if(empty($value)) return $value;
  35. $arr = explode(',', $value);
  36. $domain = config('app.ali_oss_bindurl');
  37. foreach($arr as &$item){
  38. $item = 'https://'.$domain.'/'.$item;
  39. }
  40. return $arr;
  41. }
  42. public function getNameAttr($value, $data)
  43. {
  44. $n = ['1'=>'一', 2=>'二', 3=>'三', 4=>'四', 5=>'五', 6=>'六', 7=>'七', 8=>'八', 9=>'九'];
  45. $name = '';
  46. if ($data['room']==9) {
  47. $name='别墅';
  48. } else {
  49. if($data['room']) $name .= $n[$data['room']].'室';
  50. if($data['hall']) $name .= $n[$data['hall']].'厅';
  51. if($data['bathroom']) $name .= $n[$data['bathroom']].'卫';
  52. }
  53. return $name;
  54. }
  55. /**
  56. * 内部资料
  57. */
  58. public function file(){
  59. return $this->hasMany(BuildingHousetypeFile::class, 'housetype_id', 'id');
  60. }
  61. /**
  62. * 所属楼盘
  63. */
  64. public function building(){
  65. return $this->belongsTo(Building::class, 'building_id', 'id');
  66. }
  67. }