Skip to content

Beautiful Open-Source Form Builder

Remove disable cache in favor flush/forget

Julien Nahuma6e208a88ee3
diff --git a/app/Models/Forms/Form.php b/app/Models/Forms/Form.php
index e76f39928..6afadac9e 100644
--- a/app/Models/Forms/Form.php
+++ b/app/Models/Forms/Form.php
@@ -218,7 +218,7 @@ class Form extends Model implements CachableAttributes
public function getMaxNumberOfSubmissionsReachedAttribute()
{
- $this->disableCache('submissions_count');
+ $this->forget('submissions_count');
return ($this->max_submissions_count && $this->max_submissions_count <= $this->submissions_count);
}
diff --git a/app/Models/Traits/CachesAttributes.php b/app/Models/Traits/CachesAttributes.php
index b70d41632..0b035d204 100644
--- a/app/Models/Traits/CachesAttributes.php
+++ b/app/Models/Traits/CachesAttributes.php
@@ -20,8 +20,6 @@ trait CachesAttributes
/** @var array<string, mixed> */
protected $attributeCache = [];
- protected $disabledCache = [];
-
public static function bootCachesAttributes(): void
{
static::deleting(function (Model $model): void {
@@ -30,18 +28,8 @@ trait CachesAttributes
});
}
- public function disableCache($key)
- {
- $this->disabledCache[] = $key;
- return $this;
- }
-
public function remember(string $attribute, ?int $ttl, Closure $callback)
{
- if (in_array($attribute, $this->disabledCache)) {
- return value($callback);
- }
-
if ($ttl === 0 || ! $this->exists) {
if (! isset($this->attributeCache[$attribute])) {
$this->attributeCache[$attribute] = value($callback);