50], [['addon_name'], 'string', 'max' => 100], [['message'], 'string', 'max' => 1000], [['type', 'event'], 'string', 'max' => 20], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'merchant_id' => '商户id', 'store_id' => '店铺ID', 'rule_id' => '规则id', 'keyword_id' => '关键字id', 'openid' => 'openId', 'module' => '触发模块', 'is_addon' => '是否插件', 'addon_name' => '插件名称', 'message' => '微信消息', 'type' => 'Type', 'event' => '详细事件', 'status' => '状态', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } /** * 关联粉丝 * * @return \yii\db\ActiveQuery */ public function getFans() { return $this->hasOne(Fans::class, ['openid' => 'openid']); } /** * 关联授权 */ public function getAuth() { return $this->hasOne(Auth::class, ['oauth_client_user_id' => 'openid']); } /** * 关联规则 * * @return \yii\db\ActiveQuery */ public function getRule() { return $this->hasOne(Rule::class, ['id' => 'rule_id']); } /** * @param bool $insert * @return bool */ public function beforeSave($insert) { if ($this->isNewRecord) { !empty($this->addon_name) && $this->is_addon = 1; } return parent::beforeSave($insert); } }