Skip to content

Commit

Permalink
Merge pull request #730 from ahmedabdel3al/master
Browse files Browse the repository at this point in the history
run  attributeValuesToBeLogged  method before getDescripotionForEvent in LogsActivity trait
  • Loading branch information
Gummibeer authored Sep 16, 2020
2 parents 8ff2cfc + cf0f6dc commit 01392f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/Traits/LogsActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@ protected static function bootLogsActivity()
if (! $model->shouldLogEvent($eventName)) {
return;
}
$attrs = $model->attributeValuesToBeLogged($eventName);

$description = $model->getDescriptionForEvent($eventName);

$logName = $model->getLogNameToUse($eventName);

if ($description == '') {
if ($model->isLogEmpty($attrs) && ! $model->shouldSubmitEmptyLogs()) {
return;
}
$description = $model->getDescriptionForEvent($eventName, $attrs);

$attrs = $model->attributeValuesToBeLogged($eventName);
$logName = $model->getLogNameToUse($eventName);

if ($model->isLogEmpty($attrs) && ! $model->shouldSubmitEmptyLogs()) {
if ($description == '') {
return;
}

Expand Down Expand Up @@ -83,7 +81,7 @@ public function activities(): MorphMany
return $this->morphMany(ActivitylogServiceProvider::determineActivityModel(), 'subject');
}

public function getDescriptionForEvent(string $eventName): string
public function getDescriptionForEvent(string $eventName, array $attributes): string
{
return $eventName;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/LogsActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function it_will_not_fail_if_asked_to_replace_from_empty_attribute()
use LogsActivity;
use SoftDeletes;

public function getDescriptionForEvent(string $eventName): string
public function getDescriptionForEvent(string $eventName, array $attributes): string
{
return ":causer.name $eventName";
}
Expand Down

0 comments on commit 01392f7

Please sign in to comment.