256], [['type'], 'string', 'max' => 16], [['avatar_url'], 'string', 'max' => 2048], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'cx_mch_id' => '平台商户ID', 'type' => '类型', 'user_id' => '用户ID', 'openid' => 'OPENID', 'unionid' => 'UNIONID', 'nickname' => '昵称', 'avatar_url' => '头像', 'is_delete' => '是否删除,0=否,1=是', 'created_at' => '添加时间', ]; } public function beforeSave($insert) { if(parent::beforeSave($insert)){ if($this->isNewRecord){ $this->created_at = time(); } return true; } else { return false; } } public function getUser() { return $this->hasOne(User::className(),['id' => 'user_id']); } }