This is a compilation of common problems and their respective solutions and/or workarounds.
Auditing not working
You followed the documentation to the letter and yet, audit records aren't being created?
This package relies on Eloquent events and if they don't fire, there's no way to know something happened.
The most common mistake is doing an
delete using a
Builder instance, rather than an using an Eloquent
Usually, something like this is used:
When in fact, it should be:
Error: Call to undefined method Closure::__set_state()
This error happens when Laravel is set to cache the configuration.
By default, the
User resolver is a
Closure in the
config/audits.php file, which causes this issue.
To overcome this, the resolver should be set as a FQCN instead.
User resolver section in the General Configuration for more information.
Attributes are considered modified, when they're not
False positives cause Audit records to be created. This happens when model attributes are updated with BOOLEAN and/or DATE values.
The internal data of the Eloquent model will be as follows:
In the $attributes array attribute:
In the $original array attribute:
This makes the
isDirty() methods to consider wrongful attribute changes when comparing data.
According to a maintainer, this is an expected behaviour.
As a workaround, consider passing
0, instead of
false. For date values, append
At the time of writing, this is the only open issue about this subject.
Argument 1 passed to Illuminate\Database\Eloquent\Model::serializeDate() must implement interface DateTimeInterface, null given
This might happen in version 4.1.x, because the
updated_at column values in the
audits table are set to
After upgrading the table schema for 4.1.x, don't forget to set the
updated_at values to match the ones from
Read the upgrading documentation for more information.