Skip to content

Commit

Permalink
Merge pull request #849 from erikn69/port-831
Browse files Browse the repository at this point in the history
Merge v13 fixes into v14 branch
  • Loading branch information
MortenDHansen authored Aug 24, 2023
2 parents a04093f + 6d53320 commit 11d56a4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
}
},
"suggest": {
"laravelista/lumen-vendor-publish": "Needed to publish the package configuration in Lumen"
"irazasyed/larasupport": "Needed to publish the package configuration in Lumen"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion src/Auditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function auditDriver(Auditable $model): AuditDriver
/**
* {@inheritdoc}
*/
public function execute(Auditable $model)
public function execute(Auditable $model): void
{
if (! $model->readyForAuditing()) {
return;
Expand Down
12 changes: 6 additions & 6 deletions src/Concerns/AuditsPivotRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public function auditAttach(string $relationName, $id, array $attributes = [], $
$this->auditEvent = 'attach';
$this->isCustomEvent = true;
$this->auditCustomOld = [
$relationName => $this->{$relationName}()->get()->isEmpty() ? [] : $this->{$relationName}()->get()->toArray(),
$relationName => $this->{$relationName}()->get()->toArray(),
];
$this->{$relationName}()->attach($id, $attributes, $touch);
$this->auditCustomNew = [
$relationName => $this->{$relationName}()->get()->isEmpty() ? [] : $this->{$relationName}()->get()->toArray(),
$relationName => $this->{$relationName}()->get()->toArray(),
];
Event::dispatch(AuditCustom::class, [$this]);
$this->isCustomEvent = false;
Expand All @@ -49,11 +49,11 @@ public function auditDetach(string $relationName, $ids = null, $touch = true)
$this->auditEvent = 'detach';
$this->isCustomEvent = true;
$this->auditCustomOld = [
$relationName => $this->{$relationName}()->get()->isEmpty() ? [] : $this->{$relationName}()->get()->toArray(),
$relationName => $this->{$relationName}()->get()->toArray(),
];
$results = $this->{$relationName}()->detach($ids, $touch);
$this->auditCustomNew = [
$relationName => $this->{$relationName}()->get()->isEmpty() ? [] : $this->{$relationName}()->get()->toArray(),
$relationName => $this->{$relationName}()->get()->toArray(),
];
Event::dispatch(AuditCustom::class, [$this]);
$this->isCustomEvent = false;
Expand All @@ -78,7 +78,7 @@ public function auditSync($relationName, $ids, $detaching = true)
$this->auditEvent = 'sync';

$this->auditCustomOld = [
$relationName => $this->{$relationName}()->get()->isEmpty() ? [] : $this->{$relationName}()->get()->toArray(),
$relationName => $this->{$relationName}()->get()->toArray(),
];

$changes = $this->{$relationName}()->sync($ids, $detaching);
Expand All @@ -88,7 +88,7 @@ public function auditSync($relationName, $ids, $detaching = true)
$this->auditCustomNew = [];
} else {
$this->auditCustomNew = [
$relationName => $this->{$relationName}()->get()->isEmpty() ? [] : $this->{$relationName}()->get()->toArray(),
$relationName => $this->{$relationName}()->get()->toArray(),
];
}

Expand Down
7 changes: 6 additions & 1 deletion src/Concerns/DeterminesAttributesToAudit.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ protected function resolveAuditExclusions(): array

// Exclude Timestamps
if (! $this->shouldAuditTimestamps()) {
array_push($excludedAttributes, $this->getCreatedAtColumn(), $this->getUpdatedAtColumn());
if ($this->getCreatedAtColumn()) {
$excludedAttributes[] = $this->getCreatedAtColumn();
}
if ($this->getUpdatedAtColumn()) {
$excludedAttributes[] = $this->getUpdatedAtColumn();
}
if (method_exists($this, 'getDeletedAtColumn')) {
$excludedAttributes[] = $this->getDeletedAtColumn();
}
Expand Down

0 comments on commit 11d56a4

Please sign in to comment.