Audit Trail Docs

AccountMappingAudit extends BaseAudit

AccountMapping audit trail implementations

Table of Contents

Methods

AccountMappingCreatedLog()  : void
Log AccountMapping creation
AccountMappingDeletedLog()  : void
Log AccountMapping deletion
AccountMappingUpdatedLog()  : void
Log AccountMapping update
AccountMappingVariationCreatedLog()  : void
Log AccountMappingVariation creation
AccountMappingVariationDeletedLog()  : void
Log AccountMappingVariation deletion
AccountMappingVariationUpdatedLog()  : void
Log AccountMappingVariation update
addAuditLog()  : void
Log an audit trail entry
getCompanyId()  : int
Extract company ID from various model types.
getUserId()  : int
Get the current authenticated user ID, or fallback to job context user ID.

Methods

AccountMappingCreatedLog()

Log AccountMapping creation

public static AccountMappingCreatedLog(mixed $record[, int $userId = 0 ]) : void
Parameters
$record : mixed

The newly created AccountMapping record

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

AccountMapping Created

audit-module

INTEGRATION_LAYER

audit-action

CREATE

audit-trigger

When a new AccountMapping is created in the system

AccountMappingDeletedLog()

Log AccountMapping deletion

public static AccountMappingDeletedLog(mixed $record[, int $userId = 0 ]) : void
Parameters
$record : mixed

The AccountMapping being deleted

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

AccountMapping Deleted

audit-module

INTEGRATION_LAYER

audit-action

DELETE

audit-trigger

When a AccountMapping is deleted from the system

AccountMappingUpdatedLog()

Log AccountMapping update

public static AccountMappingUpdatedLog(mixed $oldRecord, mixed $newRecord[, int $userId = 0 ]) : void
Parameters
$oldRecord : mixed

The AccountMapping data before the update

$newRecord : mixed

The AccountMapping data after the update

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

AccountMapping Updated

audit-module

INTEGRATION_LAYER

audit-action

UPDATE

audit-trigger

When an existing AccountMapping is updated in the system

AccountMappingVariationCreatedLog()

Log AccountMappingVariation creation

public static AccountMappingVariationCreatedLog(mixed $record[, int $userId = 0 ]) : void
Parameters
$record : mixed

The newly created AccountMappingVariation record

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

AccountMappingVariation Created

audit-module

INTEGRATION_LAYER

audit-action

CREATE

audit-trigger

When a new AccountMappingVariation is created in the system

AccountMappingVariationDeletedLog()

Log AccountMappingVariation deletion

public static AccountMappingVariationDeletedLog(mixed $record[, int $userId = 0 ]) : void
Parameters
$record : mixed

The AccountMappingVariation being deleted

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

AccountMappingVariation Deleted

audit-module

INTEGRATION_LAYER

audit-action

DELETE

audit-trigger

When a AccountMappingVariation is deleted from the system

AccountMappingVariationUpdatedLog()

Log AccountMappingVariation update

public static AccountMappingVariationUpdatedLog(mixed $oldRecord, mixed $newRecord[, int $userId = 0 ]) : void
Parameters
$oldRecord : mixed

The AccountMappingVariation data before the update

$newRecord : mixed

The AccountMappingVariation data after the update

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

AccountMappingVariation Updated

audit-module

INTEGRATION_LAYER

audit-action

UPDATE

audit-trigger

When an existing AccountMappingVariation is updated in the system

addAuditLog()

Log an audit trail entry

protected static addAuditLog(int|null $companyId, int $userId, string $message, string $module, string $action[, mixed|null $currentRecord = null ][, mixed|null $updatedRecord = null ][, string|null $objectName = null ][, string $queueName = 'audit-trails' ][, bool $afterCommit = false ][, string $type = AuditTypesEnum::COMPANY->value ]) : void
Parameters
$companyId : int|null

Company identifier, null for records that belong to no company (e.g. global payroll elements)

$userId : int

User identifier (default 0 for system actions)

$message : string

Human-readable audit message

$module : string

Module name (PAYROLL, LEAVE, PAYMENTS, etc.) - must be a valid AuditModulesEnum value

$action : string

Action type (CREATE, UPDATE, DELETE, etc.) - must be a valid AuditActionsEnum value

$currentRecord : mixed|null = null

Current data being logged

$updatedRecord : mixed|null = null

The updated data (for updates)

$objectName : string|null = null

Optional name of the object being logged - if not provided, will be inferred from the model

$queueName : string = 'audit-trails'

Optional queue name for async processing. Default 'audit-trails'

$afterCommit : bool = false

Whether to log after DB commit

$type : string = AuditTypesEnum::COMPANY->value
Tags
throws
ValueError

If invalid enum values are provided

getCompanyId()

Extract company ID from various model types.

protected static getCompanyId(mixed $model) : int

This method attempts to determine the company ID from the provided model instance.

It checks for a direct company_id property or navigates through related employee models.

Parameters
$model : mixed

Model instance

Tags
throws
Exception

When company ID cannot be determined

Return values
int —

Company ID

getUserId()

Get the current authenticated user ID, or fallback to job context user ID.

protected static getUserId() : int

This method first checks for an authenticated user via the auth() helper. If no user is authenticated, it looks for a user_id in the job context (for queued jobs).

To add a user ID to the job context, you can use this in your job setup:

 app()->instance('job_context', ['user_id' => $userId]);

If neither is available, it returns 0 to indicate a system action.

Return values
int —

The determined user ID, or 0 if none found


        
On this page

Search results