addBehavior( new SoftDelete([ 'field' => 'deleted', 'value' => 1, ]) ); } public function beforeCreate() { $this->create_time = time(); } public function beforeUpdate() { if ($this->deleted == 1) { $this->published = 0; } $this->update_time = time(); } public function afterCreate() { $cache = new MaxCategoryIdCache(); $cache->rebuild(); } public static function types() { return [ self::TYPE_COURSE => '课程', self::TYPE_HELP => '帮助', ]; } }