Skip to content

Commit

Permalink
Fixes to write log record to model removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
anteriovieira committed Dec 10, 2015
1 parent 118185a commit 1ac3d8e
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/AuditingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,38 @@ public function auditUpdate()
/**
* Audit deletion.
*
* @return mixed
* @return void
*/
public function auditDeletion()
{
if ((!isset($this->auditEnabled) || $this->auditEnabled)
&& $this->isAuditing('deleted_at')) {
return $this->audit([
'old_value' => $this->updatedData,
'new_value' => null,
], 'deleted');
if (isset($this->historyLimit) && $this->logHistory()->count() >= $this->historyLimit) {
$LimitReached = true;
} else {
$LimitReached = false;
}
if (isset($this->logCleanup)) {
$LogCleanup = $this->LogCleanup;
} else {
$LogCleanup = false;
}

if (((!isset($this->auditEnabled) || $this->auditEnabled) && $this->isAuditing('deleted_at')) && (!$LimitReached || $LogCleanup)) {
$log = ['new_value' => null];

foreach ($this->updatedData as $key => $value) {
if ($this->isAuditing($key)) {
$log['old_value'][$key] = $value;
}
}

$this->audit($log, 'deleted');
}
}

/**
* Audit model.
*
* @return OwenIt\Auditing\Log
* @return Log
*/
public function audit(array $log, $type)
{
Expand Down

0 comments on commit 1ac3d8e

Please sign in to comment.