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() { $slideListCache = new SlideListCache(); $slideListCache->rebuild(); } public static function targetTypes() { $list = [ self::TARGET_COURSE => '课程', self::TARGET_PAGE => '单页', self::TARGET_LINK => '链接', ]; return $list; } }