addBehavior( new SoftDelete([ 'field' => 'deleted', 'value' => 1, ]) ); } public function beforeCreate() { $this->key = Text::random(Text::RANDOM_ALNUM, 16); $this->secret = Text::random(Text::RANDOM_ALNUM, 16); $this->create_time = time(); } public function beforeUpdate() { if ($this->deleted == 1) { $this->published = 0; } $this->update_time = time(); } public static function types() { return [ self::TYPE_PC => 'PC客户端', self::TYPE_H5 => 'H5客户端', self::TYPE_IOS => 'IOS客户端', self::TYPE_ANDROID => 'Android客户端', self::TYPE_MP_WEIXIN => '微信小程序', self::TYPE_MP_ALIPAY => '支付宝小程序', ]; } }