120], ['type','in','range'=>[self::TYPE_SITE,self::TYPE_HOUSE]] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'pid' => '工地ID', 'type' => '类型', 'uid' => '留言人', 'reply_uid' => '回复人', 'star' => '星级', 'content' => '评价内容', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'status' => 'Status', ]; } //用户信息 public function getUserinfo(){ return $this->hasOne(UserInfo::className(),['uid'=>'uid']); } //公司信息 public function getCompanyinfo(){ return $this->hasOne(UserCompany::className(),['uid'=>'reply_uid']); } //工地信息 public function getHouseinfo(){ return $this->hasOne(Building::className(),['id'=>'pid']); } //评价回复 public function getReply(){ return $this->hasMany(Reply::className(),['cid'=>'id']); } //评论图片 public function getImgs(){ return $this->hasMany(ImageSource::className(),['topid'=>'id'])->where(['type'=>ImageSource::TYPE_COMMENT,'status'=>ImageSource::STATUS_YES]); } static function time_tran($the_time) { $now_time = time(); $show_time = $the_time; $dur = $now_time - $show_time; if($dur < 0){ return $the_time; }else{ if($dur < 60){ return $dur.'秒前'; }else{ if($dur < 3600){ return floor($dur/60).'分钟前'; }else{ if($dur < 86400){ return floor($dur/3600).'小时前'; }else{ return floor($dur/86400).'天前'; } } } } } }