addBehavior( new SoftDelete([ 'field' => 'deleted', 'value' => 1, ]) ); } public function beforeCreate() { $this->create_time = time(); } public function beforeUpdate() { $this->update_time = time(); } public function afterCreate() { $this->rebuildCache(); } public function afterUpdate() { $this->rebuildCache(); } public function rebuildCache() { $itemCache = new CategoryCache(); $itemCache->rebuild($this->id); $listCache = new CategoryListCache(); $listCache->rebuild(); $treeListCache = new CategoryTreeListCache(); $treeListCache->rebuild(); } }