From: Vincent Vanwaelscappel Date: Tue, 17 May 2022 08:12:16 +0000 (+0200) Subject: wait #5282 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8a7b812af7196a55225ada35fd429e635103f255;p=cubist_cms-back.git wait #5282 @0.25 --- diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index 97ea375..f6adeda 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -64,6 +64,8 @@ class CubistMagicAbstractModel extends Model implements HasMedia protected $_enableRevisionsButton = false; protected $_enableBulk = true; + protected $_flushCacheOnSave = true; + public $timestamps = true; protected $_enableTrackNonDefaultValues = false; @@ -878,7 +880,9 @@ class CubistMagicAbstractModel extends Model implements HasMedia protected function finishSave(array $options) { parent::finishSave($options); - $this->flushCache(); + if ($this->_flushCacheOnSave) { + $this->flushCache(); + } } public function flushCache($tags = []) @@ -1170,6 +1174,13 @@ class CubistMagicAbstractModel extends Model implements HasMedia return $saved; } + public function saveWithoutFlushingCache($options = []) + { + $this->_flushCacheOnSave = false; + $this->save($options); + $this->_flushCacheOnSave = true; + } + public static function refreshComposedAttributes() { $all = static::all();