diff --git a/src/Auditable.php b/src/Auditable.php index aefe923..7471b9f 100644 --- a/src/Auditable.php +++ b/src/Auditable.php @@ -30,10 +30,10 @@ public function initializeAuditable() */ protected static function bootAuditable() { - $user = Auth::id() ?? null; - // Creating && Updating - self::saving(function ($item) use ($user) { + self::saving(function ($item) { + $user = Auth::id() ?? null; + if ($item->timestamps) if (!$item->getKey()) { // Creating @@ -45,7 +45,9 @@ protected static function bootAuditable() }); // Deleting - static::deleting(function ($item) use ($user) { + static::deleting(function ($item) { + $user = Auth::id() ?? null; + if (is_bool($item->forceDeleting ?? null)) if (!$item->forceDeleting) { // SOFT