Remove disable cache in favor flush/forget

This commit is contained in:
Julien Nahum 2023-12-02 19:15:16 +01:00
parent 6cfa914fe8
commit a6e208a88e
2 changed files with 1 additions and 13 deletions

View File

@ -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);
}

View File

@ -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);