From 6002b76634267c08083701180b7b1a5b68eab6f7 Mon Sep 17 00:00:00 2001 From: David Cox Date: Thu, 5 Mar 2020 21:09:40 -0500 Subject: [PATCH] fix performance issue around global vs model log disabling --- composer.json | 1 + src/Traits/LogsActivity.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2bfc0d5a..a812986b 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ }, "require-dev": { "ext-json": "*", + "orchestra/testbench": "^5.0", "phpunit/phpunit": "^8.0|^9.0" }, "autoload": { diff --git a/src/Traits/LogsActivity.php b/src/Traits/LogsActivity.php index 9ccc2080..f3bf1d5d 100644 --- a/src/Traits/LogsActivity.php +++ b/src/Traits/LogsActivity.php @@ -9,6 +9,7 @@ use Illuminate\Support\Collection; use Spatie\Activitylog\ActivityLogger; use Spatie\Activitylog\ActivitylogServiceProvider; +use Spatie\Activitylog\ActivityLogStatus; trait LogsActivity { @@ -128,7 +129,9 @@ public function attributesToBeIgnored(): array protected function shouldLogEvent(string $eventName): bool { - if (! $this->enableLoggingModelsEvents) { + $logStatus = app(ActivityLogStatus::class); + + if (! $this->enableLoggingModelsEvents || $logStatus->disabled()) { return false; }