diff --git a/src/Events/AuditableEvent.php b/src/Events/AuditableEvent.php index 606c088..60a01fb 100644 --- a/src/Events/AuditableEvent.php +++ b/src/Events/AuditableEvent.php @@ -42,7 +42,7 @@ public function __construct(Model $model) if (app()->has(static::CONTAINER_KEY)) { [$user, $action] = app()->get(static::CONTAINER_KEY); - $this->user = ! $action || $this->action === $action ? $user : null; + $this->user = !$action || $this->action === $action ? $user : null; } $this->user ??= Auth::user(); diff --git a/tests/AuditableTest.php b/tests/AuditableTest.php index ba256a3..ede3557 100644 --- a/tests/AuditableTest.php +++ b/tests/AuditableTest.php @@ -141,7 +141,7 @@ public function test_updated_by_uses_forced_user_only_when_action_sent() $this->assertTrue($post->created_by === $this->user->id); $this->assertNull($post->updated_by); $this->assertNull($post->deleted_by); - + $post->update(['title' => 'hello another']); $this->assertTrue($post->updated_by === $this->anotherUser->id);