Skip to content

Commit

Permalink
Update Auditable.php
Browse files Browse the repository at this point in the history
  • Loading branch information
MoamenEltouny authored Sep 12, 2021
1 parent 44dd450 commit db187ce
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Auditable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit db187ce

Please sign in to comment.