32], [['contact'], 'string', 'max' => 120], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'uid' => 'Uid', 'type' => 'Type', 'latitude' => 'Latitude', 'longitude' => 'Longitude', 'province' => '省份编号', 'city' => '城市编号', 'district' => '地区编号', 'address' => '地址', 'created_at' => '创建时间', 'status' => 'Status', 'updated_at' => 'Updated At', 'layout' => '户型', 'acreage' => '面积', 'opening_begin' => '可约时间', 'opening_end' => '可约时间', 'contact' => '联系方式', 'stage' => '装修进度', 'pattern' => '装修模式', 'budget' => '单价', 'style' => '风格', 'name' => 'Name', 'hashcode' => 'Hashcode', 'manager_id' => '项目经理id', 'designer_id' => '设计师id', 'posted' => '是否发布', ]; } //项目经理 public function getManager(){ return $this->hasOne(Manager::className(),['id'=>'manager_id']); } //设计师 public function getDesigner(){ return $this->hasOne(Designer::className(),['id'=>'designer_id']); } //工程相关照片 public function getImage(){ return $this->hasMany(ImageSource::className(),['topid'=>'id'])->where(['bd_image.type' => [20, 30, 40,50], 'bd_image.status' => ImageSource::STATUS_YES]); } public function getAppointment(){ return $this->hasMany(Appointment::className(),['pid'=>'id'])->limit(6); } //客厅照片 public function getLiving(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>20,':status'=>ImageSource::STATUS_YES]); } //主卧照片 public function getMaster(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>30,':status'=>ImageSource::STATUS_YES]); } //局部美图 public function getPortion(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>40,':status'=>ImageSource::STATUS_YES]); } //局部美图2 public function getPortion2(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>ImageSource::TYPE_PORTION2,':status'=>ImageSource::STATUS_YES]); } //局部美图3 public function getPortion3(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>ImageSource::TYPE_PORTION3,':status'=>ImageSource::STATUS_YES]); } //局部美图4 public function getPortion4(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>ImageSource::TYPE_PORTION4,':status'=>ImageSource::STATUS_YES]); } //局部美图5 public function getPortion5(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>ImageSource::TYPE_PORTION5,':status'=>ImageSource::STATUS_YES]); } //平面图 public function getFlat(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>50,':status'=>ImageSource::STATUS_YES]); } //施工图 public function getBuild(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>ImageSource::TYPE_BUILD,':status'=>ImageSource::STATUS_YES]); } //施工图2 public function getBuild2(){ return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>ImageSource::TYPE_BUILD2,':status'=>ImageSource::STATUS_YES]); } //所有图片的第一张 public function getAll(){ //return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type or type=:type1 or type=:type2 or type=:type3',[':type'=>20,':type1'=>30,':type2'=>40,':type3'=>50,]); return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where(['type'=>[ImageSource::TYPE_LIVING_ROOM,ImageSource::TYPE_MASTER_BEDROOM,ImageSource::TYPE_PORTION,ImageSource::TYPE_FLAT,ImageSource::TYPE_PORTION2,ImageSource::TYPE_PORTION3,ImageSource::TYPE_PORTION4,ImageSource::TYPE_PORTION5,ImageSource::TYPE_BUILD,ImageSource::TYPE_BUILD2],'status'=>ImageSource::STATUS_YES]); } //所有图片 public function getAllimg(){ //return $this->hasMany(ImageSource::className(),['topid'=>'id'])->where('type=:type or type=:type1 or type=:type2 or type=:type3',[':type'=>20,':type1'=>30,':type2'=>40,':type3'=>50,]); return $this->hasMany(ImageSource::className(),['topid'=>'id'])->where(['type'=>[ImageSource::TYPE_LIVING_ROOM,ImageSource::TYPE_MASTER_BEDROOM,ImageSource::TYPE_PORTION,ImageSource::TYPE_FLAT,ImageSource::TYPE_PORTION2,ImageSource::TYPE_PORTION3,ImageSource::TYPE_PORTION4,ImageSource::TYPE_PORTION5,ImageSource::TYPE_BUILD,ImageSource::TYPE_BUILD2],'status'=>ImageSource::STATUS_YES]); } public function getCompany() { return $this->hasOne(UserCompany::className(),['uid'=>'uid']); } }