From 2be6f07eecfe5b737f9b33a420db3fc3edd1e9fd Mon Sep 17 00:00:00 2001 From: David Tinoco Date: Wed, 18 Sep 2024 12:30:49 -0400 Subject: [PATCH 1/5] allows for merging excludes into the config exclude list --- src/Auditable.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Auditable.php b/src/Auditable.php index 3696afb2..bd936bc5 100644 --- a/src/Auditable.php +++ b/src/Auditable.php @@ -143,6 +143,14 @@ protected function resolveAuditExclusions() */ public function getAuditExclude(): array { + if(property_exists($this, 'auditExcludeMerge')) + { + return array_merge( + $this->auditExcludeMerge, + Config::get('audit.exclude', []) + ); + } + return $this->auditExclude ?? Config::get('audit.exclude', []); } From ece16e5df438d7b3c2543e17cf1f5df24e99839c Mon Sep 17 00:00:00 2001 From: David Tinoco Date: Wed, 18 Sep 2024 16:02:07 -0400 Subject: [PATCH 2/5] Update Auditable.php - Merge local model auditExclude with config exclude Allows for merging the model's audit exclude with the config default exclude list, instead of replacing it. --- src/Auditable.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Auditable.php b/src/Auditable.php index bd936bc5..28db52d0 100644 --- a/src/Auditable.php +++ b/src/Auditable.php @@ -143,12 +143,8 @@ protected function resolveAuditExclusions() */ public function getAuditExclude(): array { - if(property_exists($this, 'auditExcludeMerge')) - { - return array_merge( - $this->auditExcludeMerge, - Config::get('audit.exclude', []) - ); + if ($this->auditExcludeMerge ?? false) { + return array_merge($this->auditExclude ?? [], Config::get('audit.exclude', [])); } return $this->auditExclude ?? Config::get('audit.exclude', []); From 6d8ca0f4894134f45b1892ab4768f582797cbb00 Mon Sep 17 00:00:00 2001 From: David Tinoco Date: Wed, 18 Sep 2024 16:37:23 -0400 Subject: [PATCH 3/5] Update audit.php --- config/audit.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/audit.php b/config/audit.php index d6cee429..84d12b81 100644 --- a/config/audit.php +++ b/config/audit.php @@ -86,6 +86,19 @@ 'exclude' => [], + /* + |-------------------------------------------------------------------------- + | Global exclusion merge + |-------------------------------------------------------------------------- + | + | If set to true, the local model auditExclude array values will be + | merged with the config exclude array values instead of replacing + | them. + | + */ + + 'exclude_merge' => false, + /* |-------------------------------------------------------------------------- | Empty Values From 124aa522f91d47277d74f4b25dee136257bbffea Mon Sep 17 00:00:00 2001 From: David Tinoco Date: Wed, 18 Sep 2024 16:44:20 -0400 Subject: [PATCH 4/5] Update Auditable.php - check for global auditExclude property When getting the auditExclude values, check for global config audit.exclude_merge property and merge if enabled, instead of replace. Otherwise, check locally at the model level. --- src/Auditable.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Auditable.php b/src/Auditable.php index 28db52d0..5b2209d2 100644 --- a/src/Auditable.php +++ b/src/Auditable.php @@ -143,7 +143,10 @@ protected function resolveAuditExclusions() */ public function getAuditExclude(): array { - if ($this->auditExcludeMerge ?? false) { + if ( + Config::get('audit.exclude_merge', false) || + ($this->auditExcludeMerge ?? false) + ) { return array_merge($this->auditExclude ?? [], Config::get('audit.exclude', [])); } From dac39b9d35869b06a5da64cac861c25ab8a9889a Mon Sep 17 00:00:00 2001 From: David Tinoco Date: Wed, 18 Sep 2024 18:07:18 -0400 Subject: [PATCH 5/5] Update Auditable.php Simplify the merge condition check --- src/Auditable.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Auditable.php b/src/Auditable.php index 5b2209d2..d25ccb1a 100644 --- a/src/Auditable.php +++ b/src/Auditable.php @@ -144,8 +144,7 @@ protected function resolveAuditExclusions() public function getAuditExclude(): array { if ( - Config::get('audit.exclude_merge', false) || - ($this->auditExcludeMerge ?? false) + $this->auditExcludeMerge ?? Config::get('audit.exclude_merge', false) ) { return array_merge($this->auditExclude ?? [], Config::get('audit.exclude', [])); }