trait AuditableTrait

Trait Auditable to be used in Models

Assumes presence of these members

Properties

static protected bool $auditingDisabled

Is auditing disabled?

protected $auditExcludedProperties
Controller read-only $mod
array read-only $properties
string read-only $table_name

Methods

AuditTrail|null
addAuditTrail(string $event = AuditableInterface::AUDIT_EVENT_MISC, string|null $customMessage = null)

No description

array
getAuditEvents()

Get audit events

array
getAuditExcludeProperties()

Get the (Auditable) properties excluded from audit.

array
getAuditIncludeProperties()

Get the auditable properties to include in audit Defaults to all attributes in the DB Schema

getAuditTrail(int $limit = 50)

Get the last auditTrail records for current Model

initAuditableTrait()

Init Method

bool
isAuditingEnabled()

Determine whether auditing is enabled.

triggerAuditEvent(Model $model, string $eventKey = AuditableInterface::OBSERVE_EVENT_SAVE)

TBD: Move this method to the audit model? and keep things slim in trait?

Details

at line 97
AuditTrail|null addAuditTrail(string $event = AuditableInterface::AUDIT_EVENT_MISC, string|null $customMessage = null)

No description

Parameters

string $event
string|null $customMessage

Return Value

AuditTrail|null

Exceptions

AuditException

See also

AuditableInterface::addAuditTrail

at line 166
array getAuditEvents()

Get audit events

Return Value

array

at line 220
array getAuditExcludeProperties()

Get the (Auditable) properties excluded from audit.

Defaults to primary_key and timestamps

Return Value

array

at line 199
array getAuditIncludeProperties()

Get the auditable properties to include in audit Defaults to all attributes in the DB Schema

Return Value

array

at line 183
AuditTrail[]|ModelCollection getAuditTrail(int $limit = 50)

Get the last auditTrail records for current Model

Parameters

int $limit

Return Value

AuditTrail[]|ModelCollection

at line 43
initAuditableTrait()

Init Method

at line 233
bool isAuditingEnabled()

Determine whether auditing is enabled.

Defaults to true for Frontend/UI Actions and false for CLI/Console Actions

Return Value

bool

at line 59
triggerAuditEvent(Model $model, string $eventKey = AuditableInterface::OBSERVE_EVENT_SAVE)

TBD: Move this method to the audit model? and keep things slim in trait?

Parameters

Model $model
string $eventKey

Exceptions

AuditException