diff --git a/src/Services/CacheControl.php b/src/Services/CacheControl.php index 20daccc..f21c54c 100644 --- a/src/Services/CacheControl.php +++ b/src/Services/CacheControl.php @@ -68,6 +68,7 @@ public function getCachableMatrix(Response $response): Collection 'urlIsCachable' => $this->urlIsCachable(), 'responseIsCachable' => $this->responseIsCachable($response), 'statusCodeIsCachable' => $this->statusCodeIsCachable($response), + 'METHOD' => EdgeFlush::getRequest()->getMethod(), ]); } diff --git a/src/Services/Entity.php b/src/Services/Entity.php index d66b30c..8d73011 100644 --- a/src/Services/Entity.php +++ b/src/Services/Entity.php @@ -28,6 +28,8 @@ class Entity public array $relations = []; + protected Collection $modelNames; + public function __construct(Model $model, string|null $event = null) { $this->absorb($model); @@ -126,7 +128,7 @@ public function makeEvent(Model $model, string|null $event = null): void public function getDirtyModelNames(): Collection { - $modelNames = Helpers::collect(); + $this->modelNames = $this->modelNames ?? Helpers::collect(); foreach ($this->attributes as $key => $value) { $castType = gettype($value); @@ -143,9 +145,11 @@ public function getDirtyModelNames(): Collection $modelName .= "[attribute:{$key}]"; } - Helpers::debug("ATTRIBUTE CHANGED: {$modelName}"); + if (!isset($this->modelNames[$modelName])) { + Helpers::debug("ATTRIBUTE CHANGED: {$modelName}"); - $modelNames[$modelName] = $modelName; + $this->modelNames[$modelName] = $modelName; + } } } } @@ -159,14 +163,16 @@ public function getDirtyModelNames(): Collection $modelName .= "[relation:{$name}]"; } - Helpers::debug("RELATION CHANGED: {$modelName}"); + if (!isset($this->modelNames[$modelName])) { + Helpers::debug("RELATION CHANGED: {$modelName}"); - $modelNames[$modelName] = $modelName; + $this->modelNames[$modelName] = $modelName; + } } } } - return $modelNames; + return $this->modelNames; } public function getOriginal(string $key): mixed