Skip to content

Commit 9cebc5f

Browse files
authored
Merge pull request #3 from Hourja/Fix-Exlusion-Inclusion-Model-Fields
[Bug Fix] Auditable Trait incorrectly ignoring inclusion and exclusion variables
2 parents 99510e1 + 1e10cae commit 9cebc5f

File tree

2 files changed

+404
-5
lines changed

2 files changed

+404
-5
lines changed

src/Traits/Auditable.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function bootAuditable(): void
3333
entityId: $model->getKey(),
3434
action: 'created',
3535
oldValues: null,
36-
newValues: $model->getAttributes(),
36+
newValues: $model->getAuditableAttributes($model->getAttributes()),
3737
metadata: $model->getAuditMetadata(),
3838
causerType: $causer['type'],
3939
causerId: $causer['id'],
@@ -45,8 +45,8 @@ public static function bootAuditable(): void
4545

4646
static::updated(function (Model $model) {
4747
if ($model->isAuditingEnabled()) {
48-
$oldValues = $model->getOriginal();
49-
$newValues = $model->getChanges();
48+
$oldValues = $model->getAuditableAttributes($model->getOriginal());
49+
$newValues = $model->getAuditableAttributes($model->getChanges());
5050

5151
$oldValues = array_intersect_key($oldValues, $newValues);
5252

@@ -81,7 +81,7 @@ public static function bootAuditable(): void
8181
entityType: $model->getAuditEntityType(),
8282
entityId: $model->getKey(),
8383
action: 'deleted',
84-
oldValues: $model->getOriginal(),
84+
oldValues: $model->getAuditableAttributes($model->getOriginal()),
8585
newValues: null,
8686
metadata: $model->getAuditMetadata(),
8787
causerType: $causer['type'],
@@ -104,7 +104,7 @@ public static function bootAuditable(): void
104104
entityId: $model->getKey(),
105105
action: 'restored',
106106
oldValues: null,
107-
newValues: $model->getAttributes(),
107+
newValues: $model->getAuditableAttributes($model->getAttributes()),
108108
metadata: $model->getAuditMetadata(),
109109
causerType: $causer['type'],
110110
causerId: $causer['id'],

0 commit comments

Comments
 (0)