Skip to content

Commit 40fbbe1

Browse files
fix: RecordCustomAudit listener (#963)
Co-authored-by: Will Power <[email protected]>
1 parent 792f8e2 commit 40fbbe1

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/Auditable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ private function dispatchRelationAuditEvent($relationName, $event, $old, $new)
850850

851851
$this->auditEvent = $event;
852852
$this->isCustomEvent = true;
853-
Event::dispatch(AuditCustom::class, [$this]);
853+
Event::dispatch(new AuditCustom($this));
854854
$this->auditCustomOld = $this->auditCustomNew = [];
855855
$this->isCustomEvent = false;
856856
}

src/Listeners/RecordCustomAudit.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
namespace OwenIt\Auditing\Listeners;
44

5+
use OwenIt\Auditing\Events\AuditCustom;
56
use OwenIt\Auditing\Facades\Auditor;
67

78
class RecordCustomAudit
89
{
9-
public function handle(\OwenIt\Auditing\Contracts\Auditable $model): void
10+
public function handle(AuditCustom $event): void
1011
{
11-
Auditor::execute($model);
12+
Auditor::execute($event->model);
1213
}
1314
}

tests/Functional/AuditingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ public function canAuditAnyCustomEvent()
10801080
$article->auditCustomNew = [
10811081
'customExample' => 'Darth Vader'
10821082
];
1083-
Event::dispatch(AuditCustom::class, [$article]);
1083+
Event::dispatch(new AuditCustom($article));
10841084

10851085
$this->assertDatabaseHas(config('audit.drivers.database.table', 'audits'), [
10861086
'auditable_id' => $article->id,

0 commit comments

Comments
 (0)