Skip to content

Commit

Permalink
Added check for empty attributes (#6)
Browse files Browse the repository at this point in the history
Co-authored-by: Adonis Krasniqi <akrasniqi@one2tek.com>
  • Loading branch information
adoniskrasniqi and one2tek-ak authored Apr 21, 2022
1 parent eb6eda9 commit 6b57a7a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Traits/ModelEventLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ protected static function bootModelEventLogger()

// Created
self::created(function ($model) {
if (empty($model->getDirtyAttributes())) {
return;
}

$data = [
'event_type' => 'created',
'subject_type' => get_class($model),
Expand All @@ -39,6 +43,10 @@ protected static function bootModelEventLogger()

// Updated
self::updated(function ($model) {
if (empty($model->getDirtyAttributes())) {
return;
}

$data = [
'event_type' => 'updated',
'subject_type' => get_class($model),
Expand Down

0 comments on commit 6b57a7a

Please sign in to comment.