andWhere(['del'=>1]); if (is_string($input)) { $query->andWhere(['id' => json_decode($input, true)]); } if(is_array($input)) { $query->andWhere(['name' => $input]); } $res = $query->asArray()->all(); if(!empty($res)) { return array_column($res,'name','id'); } } //楼盘建筑类别architecture_type 2 楼盘物业类型type 1 楼盘标签 PropertyTag 3 public function HouseAlllabel($input,$type) { if (!isset($input)) return false; $query = \common\models\CategoryLabel::find()->andWhere(['del' => 1]); if (is_string($input)) { $query->andWhere(['id' => json_decode($input, true)]); } if(is_array($input)) { $query->andWhere(['name' => $input]); } $res = $query->andFilterWhere(['type'=>$type])->asArray()->all(); if(!empty($res)) { return array_column($res,'name','id'); } } //热门楼盘 public function HouseHot($hot) { //是否热门楼盘 $hotArr = [1=>'非热门',2=>'非热门']; if(!isset($hot) || empty($hot)) return false; if(is_numeric($hot)) { return $hotArr[$hot]; } else { return array_flip($hotArr)[$hot]; } } //主推楼盘 public function HouseisPush($isPush) { //是否热门楼盘 $is_pushArr = [1=>'否',2=>'是']; if(!isset($isPush) || empty($isPush)) return false; if(is_numeric($isPush)) { return $is_pushArr[$isPush]; } else { return array_flip($is_pushArr)[$isPush]; } } //装修状况 public function HouseFit($fit) { if(isset(Yii::$app->params['Housefit'])) { $fitArr = Yii::$app->params['Housefit']; if(is_numeric($fit)) { return $fitArr[$fit]; } else { return array_flip($fitArr)[$fit]; } } } //楼盘状态 public function HouseState($state) { if(isset(Yii::$app->params['HouseSalesStatus'])) { $stateArr = Yii::$app->params['HouseSalesStatus']; if(is_numeric($state)) { return $stateArr[$state]; } else { return array_flip($stateArr)[$state]; } } } //区域 public function HouseCity($city) { if(!isset($city) || empty($city)) return false; $query = \common\models\CategoryCity::find()->andWhere(['del'=>1]); if(is_numeric($city)) { $query->andWhere(['id'=>$city]); } else { $query->andWhere(['city_name'=>$city]); } $res = $query->one(); if(!empty($res['id'])) { return $res; } } //数组处理 public function addArrJson($arr) { if(!empty($arr) && is_array($arr)) { return '["'.implode('","', array_values(array_flip($arr))).'"]'; } } }