public function prepareAudit()
{
$this->originalData = $this->original;
$this->updatedData = $this->attributes;
foreach ($this->updatedData as $attribute => $val) {
if (gettype($val) == 'object' && !method_exists($val, '__toString')) {
unset($this->originalData[$attribute], $this->updatedData[$attribute]);
$this->dontKeep[] = $attribute;
}
}
// Dont keep audit of
$this->dontKeep = isset($this->dontKeepAuditOf) ? array_merge($this->dontKeepAuditOf, $this->dontKeep) : $this->dontKeep;
// Keep audit of
$this->doKeep = isset($this->keepAuditOf) ? array_merge($this->keepAuditOf, $this->doKeep) : $this->doKeep;
// Get User ID
$this->auditUserId = $this->getLoggedInUserId();
// Get current URL
$this->auditCurrentUrl = $this->getCurrentUrl();
// Get IP address
$this->auditIpAddress = $this->getIpAddress();
// Get changed data
$this->dirtyData = $this->getDirty();
// Tells whether the record exists in the database
$this->updating = $this->exists;
}