addBehavior( new SoftDelete([ 'field' => 'deleted', 'value' => 1, ]) ); } public function beforeCreate() { $this->created_at = time(); } public function beforeUpdate() { $this->updated_at = time(); } public function afterCreate() { $this->rebuildCache(); } public function afterUpdate() { $this->rebuildCache(); } public function rebuildCache() { $categoryCache = new CategoryCache(); $categoryCache->rebuild($this->id); $categoryListCache = new CategoryListCache(); $categoryListCache->rebuild(); $categoryTreeListCache = new CategoryTreeListCache(); $categoryTreeListCache->rebuild(); } }