hasMany(BuildingMaterialCase::class, 'housetype_id', 'id'); } public function devcase(){ return $this->hasMany(BuildingDevelopCase::class, 'housetype_id', 'id'); } public function getHouseImgAttr($value) { if (empty($value)) return []; $arr = explode(',', $value); $ali_oss_bindurl = config('app.ali_oss_bindurl'); foreach($arr as &$item){ $item = 'https://'.$ali_oss_bindurl.'/'.$item; } return $arr; } public function setHouseImgAttr($value){ $domain = config('app.ali_oss_bindurl'); $search = 'https://'.$domain.'/'; return str_replace($search, '', $value); } public function getOrientationAttr($value) { if (empty($value)) return '朝向暂无'; $xin = str_replace(',','|',$value); return $xin; } public function getImgContentAttr($value){ if(empty($value)) return $value; $arr = explode(',', $value); $domain = config('app.ali_oss_bindurl'); foreach($arr as &$item){ $item = 'https://'.$domain.'/'.$item; } return $arr; } public function getNameAttr($value, $data) { $n = ['1'=>'一', 2=>'二', 3=>'三', 4=>'四', 5=>'五', 6=>'六', 7=>'七', 8=>'八', 9=>'九']; $name = ''; if ($data['room']==9) { $name='别墅'; } else { if($data['room']) $name .= $n[$data['room']].'室'; if($data['hall']) $name .= $n[$data['hall']].'厅'; if($data['bathroom']) $name .= $n[$data['bathroom']].'卫'; } return $name; } /** * 内部资料 */ public function file(){ return $this->hasMany(BuildingHousetypeFile::class, 'housetype_id', 'id'); } /** * 所属楼盘 */ public function building(){ return $this->belongsTo(Building::class, 'building_id', 'id'); } }