New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

qiick/laravel-audit

Shared audit log for qiick Laravel products: the activity_log table, a secret-safe logging trait, server-side attribution, GDPR anonymisation and two-floor retention.
1,380

Larablocks Analysis

qiick/laravel-audit works with Laravel 12 and 13 (latest release v0.1.0-beta.2, Nov 29, 2026).

Recommendation checks

Use with care

Use with care: meets 2 of 5 checks.

  • Works with Laravel 13, the current version
  • Pre-release in the last 12 months (Nov 29, 2026); no stable release yet
  • First released under 90 days ago
  • 1,380 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Too new to judge
  • Last release (pre-release): Nov 29, 2026.
  • 2 releases in the last 12 months, all pre-releases.
  • First released: Nov 26, 2026.
  • Monthly downloads: 1,380.
  • 9 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.

Install
composer require qiick/laravel-audit:v0.1.0-beta.2
Latest Version:v0.1.0-beta.2
PHP:^8.4
Laravel:12 · 13
License:MIT
Last Updated:Dec 1, 2026
Links: GitHub  ·  Packagist
Maintainer: LucaGiardi20

laravel-audit: Audit log core for Laravel products

qiick/laravel-audit

OpenSSF Scorecard

PHPStan at max and the existing CI checks cover PHP. CodeQL covers GitHub Actions and JavaScript/TypeScript.

Pre-release. 0.1.0-beta.2 is on Packagist for qiick products. Do not depend on it outside the fleet before 1.0.0.

Shared audit log for qiick Laravel products, on top of spatie/laravel-activitylog v5: the common activity_log table (string morph ids, public_id, an optional organisation_id), a logging trait with a secret floor, server-side attribution (who acted, through which credential), a GDPR anonymisation contract and a two-floor retention purge. Product audit tables stay in the products.

Part of the qiick fleet. Binding design: projects/qiick/packages/laravel-audit-design.md in the knowledge base (decisions: decisions/2026-11-23-pre-1-0-extractions.md).

Status

Pre-release: 0.1.0-beta.2, on Packagist. Public APIs may change in any 0.x release, each break recorded in UPGRADING.md. The contract that freezes at 1.0.0 is listed in docs/public-api.md.

Requirements

  • PHP ^8.4. spatie/laravel-activitylog v5, which the design and every product build on, requires PHP 8.4, so the package cannot support 8.3.
  • Illuminate console / contracts / database / http / support ^12.0 || ^13.0 (never laravel/framework)
  • spatie/laravel-activitylog ^5.1.3: earlier 5.x releases write causer_id by name in the logger (causedByAnonymous(), the default causer), which audit.columns cannot follow
  • Optional: qiick/laravel-access, which fills actor_kind from its actor context.

Install

composer require qiick/laravel-audit:^0.1@beta
php artisan vendor:publish --tag=audit-config
php artisan migrate

A product that already has its own activity_log table follows "Adopting the package in a product" in UPGRADING.md instead.

Configuration

Key Default Meaning
audit.sensitive_attributes password, remember_token, two_factor_secret, two_factor_recovery_codes, key_hash, previous_key_hash, secret, token_hash, private_key logged as [redacted], on top of the built-in names and parts and encrypted* / hashed casts
audit.sensitive_parts [] extra name parts that make a value secret (other languages)
audit.personal_keys [] extra property keys the anonymiser scrubs
audit.erasure_tombstone erased one fleet erasure replacement shared by all people
audit.user_agent_max_length 512 stored user agent length
audit.retention_days 365 general retention floor
audit.security_log_names auth, security, access, api-keys the security logs, kept longer
audit.security_retention_days 730 security logs retention floor
audit.prune.schedule true the provider schedules the purge daily
audit.prune.time 03:00 when the scheduled purge runs, UTC
audit.prune.chunk_size 1000 rows deleted per statement
audit.migrations.load true (AUDIT_MIGRATIONS_LOAD) load the package's activity_log migration
audit.columns subject_id / causer_id morph id columns (externa 1.x only changes them)

Schema

The package owns the activity_log migration (Spatie's table name and columns, so Spatie keeps working):

Column Type Notes
id bigint internal, never leaves the database
public_id uuid, unique UUID v7, generated by the model; the id resources and exports use
log_name, event string; event indexed, log_name indexed with created_at Spatie
description text Spatie
subject_type / subject_id, causer_type / causer_id string / string(64) morphs for bigint, UUID and ULID keys; indexes subject, causer
organisation_id uuid, nullable, indexed with created_at tenant perimeter
attribute_changes, properties json Spatie v5
schema_version unsigned small int, default 1 row format: 1 current, 0 legacy externa row
request_id string(128), indexed correlation with application logs (http-basics accepts up to 128 characters)
anonymised_at datetime set by the anonymiser
created_at, updated_at datetime (never MySQL TIMESTAMP, which ends in 2038); created_at NOT NULL, indexed UTC

There are no foreign keys: activity morphs never cascade, and audit rows are anonymised, never deleted on erasure. In production the migration's down() refuses to drop a table that has rows; migrate:fresh and db:wipe drop tables without down(), so never run them against a production database. The package sets activitylog.activity_model to Qiick\Audit\Models\Activity and activitylog.actions.log_activity to Qiick\Audit\Actions\LogActivityAction unless the product configured subclasses of its own.

Logging trait

use Qiick\Audit\Concerns\LogsActivityTrait;

final class Project extends Model
{
    use LogsActivityTrait;

    // Optional: a log name or extra excludes. The secret floor still applies.
    public function getActivitylogOptions(): LogOptions
    {
        return $this->auditActivityLogOptions()->useLogName('projects')->logExcept(['notes']);
    }
}

The trait never logs a secret value, but it logs that a secret changed: the value becomes [redacted] and the key stays, so "the password changed" is in the log. A value is secret when the model casts it as encrypted* or hashed, when its name (in any spelling: privateKey, remember-token, X-Api-Key) is on the floor (the built-in names, audit.sensitive_attributes), or when its name contains a secret part: password, secret, token, private_key, api_key, two_factor, recovery_code, remember, passphrase, passwd, credential, authorization, cookie, session, segreto, plus audit.sensitive_parts (for names in other languages). A name with a secret part is not redacted when the name ends in _at / _on or the cast is a date, a boolean or an integer: two_factor_confirmed_at records who turned two-factor on, and its value is a time. Short abbreviations (pwd, pass, otp, pin, cvv, iban, dsn) are exact names only.

This holds by name, by JSON path (settings->secret), through a relation (owner.password) and at any depth inside a logged JSON value. A relation logged by name (owner, owner.owner) and any value that holds a model are not logged at all. Description placeholders read only attributes and relations already loaded on the model, never call a model method, and stay as written for a secret or a non-scalar value.

The floor works on names. An accessor that the model logs is the model's responsibility: one that returns a related model's toArray() or a secret under an ordinary name is logged as it returns it.

Audit rows are written once: the model refuses to update or delete a stored row, with or without model events (saveQuietly(), deleteQuietly(), Model::withoutEvents()), and the package columns are not mass-assignable, even inside Model::unguarded(). This guards against mistakes, not against product code: Activity::query()->update() and ->delete() go through the query builder, which the anonymiser and the purge use, and the model cannot stop them. Never write to activity_log that way.

Trust boundary

The package protects the log against mistakes in application code, not against code that sets out to change it. Inside the package, a test allows query-builder writes to activity_log only in the anonymiser and the retention purge. The strong guarantee is the database: give the web and queue processes a role that can INSERT and SELECT on activity_log but not UPDATE or DELETE, and run audit:prune and the erasure job with a role that can. Each row's public_id and timestamps make tampering visible only to someone who compares copies; hash chaining is after 1.0 (design §3).

For models that cause activity, use Qiick\Audit\Concerns\CausesActivityTrait (or HasActivityTrait for both): their activitiesAsCauser() / activities() relations work on PostgreSQL for bigint keys and follow audit.columns. Never use Spatie's HasActivity: it brings Spatie's LogsActivity without the secret floor.

Attribution

Every row the package logs carries server-side attribution, written after every beforeLogging callback, so a caller can never forge it:

properties key Value
ip, user_agent the routed HTTP request (user agent cut to audit.user_agent_max_length); absent in console commands and jobs
actor_kind web_session, api_key, oauth_grant, public_api or unattended
api_key_id, api_key_prefix, api_key_created_by the bound API key: public UUID, display prefix, creator's public id
oauth_client_id the bound OAuth grant's client UUID
impersonator_id reserved for impersonation (after 1.0); never written yet

A caller's value for any of these keys is removed.

The causer: when a credential acts, its owner principal replaces any causer the caller chose. Otherwise the caller's choice stands: an explicit causedBy($admin) (an admin stopping an impersonation) or causedByAnonymous() is kept, and the signed-in user is the causer when none was chosen. Description placeholders are resolved before this rule, so under a credential :causer.name names the caller's causer, not the owner.

The key or OAuth middleware binds the credential once it is verified:

use Qiick\Audit\AuditContext;
use Qiick\Audit\Data\AuditActorData;

AuditContext::bindCredential(new AuditActorData(
    causer: $apiKey->ownerPrincipal,   // the credential's owner is the causer
    actorKind: 'api_key',
    apiKeyId: $apiKey->public_id,      // UUID, never the bigint
    apiKeyPrefix: $apiKey->prefix,
    apiKeyCreatedBy: $apiKey->creator->public_id,
));

Products that wrote api_key_id through Qiick\ApiKeys\Audit::withApiKeyId() bind the credential instead: the reserved key is the server's.

The organisation goes in the organisation_id column, never in properties: either explicitly, activity()->tap(Audit::inOrganisation($organisationUuid))->log(...), or from the product's OrganisationResolverContract binding (default: none). request_id comes from the request_id key of Laravel's context, which qiick/laravel-http-basics sets.

Settings history

With qiick/laravel-settings installed, the provider binds SettingsChangeRecorderContract (with bind, so it replaces the settings no-op in either provider order; a product binding registered later still wins). Every settings write then adds one row per key, inside the settings transaction, so the row commits or rolls back with the setting:

Field Value
log_name settings
event created, updated or cleared
description settings.<event>
attribute_changes {"attributes": {"<key>": new}, "old": {"<key>": old}}; a secret is [redacted] (settings masks it, and the secret floor applies too)
properties.setting scope, scope_id (null for a user scope), organisation_id, group, key, revision, is_secret
organisation_id the setting's organisation, through Audit::inOrganisation()
subject for a user's setting, that user (resolved through the default guard's provider), so erasure scrubs the row as theirs

The causer and actor come from the usual attribution. Query a setting's history with Activity::inLog('settings') and properties->setting->key.

Transactions

  • A logged row joins the ambient transaction, as Spatie's does: the row is written with the business change it describes, and it rolls back with it. The log never says that a change happened when it did not. This coupling holds only on one connection: the activity model's connection (by default the application's default connection) must be the one the business write uses. A transaction on another connection commits and rolls back on its own.
  • Evidence of an attempt that fails (a rejected privilege change, a refused delete) is therefore lost if it is logged inside the transaction that rolls back. Log such attempts outside it: before DB::transaction() starts, or in the failure path after it has rolled back (catch (Throwable $exception) { activity('security')->...->log(...); throw $exception; }).
  • Buffered logging (activitylog.buffer.enabled), which writes after the response, is refused in production by a boot check: buffered security events are lost when the process dies.
  • Erasure joins the caller's transaction as a savepoint on the activity model's connection. The erasure event is dispatched after the outermost commit of that connection. Rolling back the audit transaction undoes the scrubbing and discards the event.
  • Concurrent erasures lock the rows they read (SELECT … FOR UPDATE on PostgreSQL, MySQL and MariaDB), so two erasures of people who share a row (one causer, the other subject) run one after the other on that row and neither writes back a name the other scrubbed.
  • The retention purge deletes in chunks, each its own statement, without a transaction of its own: a run that stops halfway leaves only rows that the next run deletes.

Erasure (GDPR)

The product orchestrator calls AuditEraser after account deletion on a full erasure, or after deactivating the principal on an organisation erasure. It passes the identifiers collected before the product removes the account data:

use Qiick\Audit\Erasure\AuditEraser;

$report = app(AuditEraser::class)->erase(
    userId: $userId,
    userPublicId: $userPublicId,
    mode: AuditEraser::DELETE,
    publicIds: [$principalPublicId, $apiKeyPublicId],
    identifiers: [$email, $username, $displayName],
    organisationId: $organisationId, // null for a full erasure
);

Both modes retain audit evidence and scrub the personal data. The report counts anonymised and kept rows, with separate counts for the subject and causer IDs and the acting and owning principal UUIDs retained in cleartext for legal_obligation. A row under legal hold (retain_until in the future) is counted as kept and left unchanged until the hold passes; run the erasure again then. A repeat run reports changed() === 0. Set dryRun: true for a preview without writes or events. A report uses legal_obligation for the whole evidence store, including security logs. Log-specific retention periods still apply. A real run dispatches SubjectErasedEvent with the report after the outermost commit on the configured activity model's connection.

Direct calls to AuditAnonymiserContract::anonymise() take an explicit ErasureSubjectData and dispatch ActivityAnonymisedEvent. A replacement binding implements AuditAnonymiserContract, which declares anonymise(), anonymiseForErasure() and ownedRowsForExport().

For the Art. 15 / 20 export step of the same orchestrator:

use Qiick\Audit\Export\AuditExporter;

$export = app(AuditExporter::class)->export(
    userId: $userId,
    userPublicId: $userPublicId,
    publicIds: [$principalPublicId, $apiKeyPublicId],
    organisationId: $organisationId, // null for a full export
);

It reads the same rows the eraser selects, with the same organisation scope, and writes nothing. The store basis is observed; each row overrides it with basis: provided when the person caused or created it, otherwise basis: observed. Rows about the person, and rows they caused with no other subject, carry full data (scope: own), without another actor's IP address, user agent, credential links or causer id; rows they only acted on for somebody else, also through their API key, carry a reference (scope: reference) with no other person's values or morph ids. Scope uses the eraser's ownership rule, so export and erasure agree row by row. The internal bigint id is omitted, secrets the person set are exported as {"value":null,"secret":true}, internal digests and signing material are omitted, and dates are RFC 3339 UTC. See docs/public-api.md for the exact JSON shape.

Erasure perimeter and caller duties

Audit erasure is one step of the product's Art. 17 erasure.

What it covers

  • Rows where the user, one of their principals or one of their keys is the causer or the subject, or where one of their keys is the recorded API credential, or that one of their principals acted on or owns (actor_principal_public_id, owner_principal_public_id). A delegated row belongs to its owner only, so an agent several people share never links one owner's rows to another. The eraser uses the alias and class name of auth.providers.users.model for the user, and matches principal and key morphs by their supplied UUIDs. It honours audit.columns and confines a scoped run to the given organisation_id, excluding rows with no organisation.
  • In those rows: the personal keys at any depth of properties, and of attribute_changes unless the person only caused a row about another subject (that subject's attributes stay; decision docs/decisions/2026-11-27-causer-only-erasure.md), in any spelling (ip, ip_address, user_agent, email, username, name, first_name, last_name, plus audit.personal_keys); every identifiers value as a whole word; every email address and phone-like sequence (8–15 digits) in any string and in description.
  • When a matched API key was used, the eraser also scrubs its display prefix. When key creation is the only link, it scrubs the supplied identifiers and UUIDs while preserving the other person's request details.

What it does not cover

  • Free text without attribution. A row solely linked to another person can still mention this person in description or a property.
  • Free text the patterns do not recognise. A postal address, a date of birth, a nickname not in identifiers, or a phone number stored as a JSON number survives unless its key is a personal key.
  • Unlisted property keys. A personal value under a key that is not a personal key and is not email- or phone-shaped stays.
  • Rows written after the run (the anonymiser is one pass over the rows it finds); run it after the account is deactivated, and run it again if needed: it is idempotent.
  • Application logs, queues and backups.

What the product must do

  1. Keep personal data out of description: put it in properties under keys the anonymiser knows, or add the product's keys to audit.personal_keys.
  2. Pass every principal and API key UUID and every free-text identifier the person is known by. Use a shared tombstone that cannot expand when one of its words is replaced with the full tombstone.
  3. Deactivate the account first, then anonymise, so no new row about the person is written during the erasure.
  4. Erase or anonymise the product's own tables, logs and backups.

Hash chain

Every organisation's rows, and the instance's, form a tamper-evident hash chain. Writes never wait on it: the hourly audit:seal (scheduled by the provider on one server unless audit.chain.schedule is false) links rows older than five minutes. php artisan audit:verify walks every chain end to end and exits non-zero on the first break; run it from monitoring. Erasure deletes each scrubbed row's personal salt and records itself in the chain, so the chain stays verifiable after erasure. The window, the limits and the payloads are in docs/reference-schema.md, "Hash chain".

Retention

Every log is kept 365 days, and the security logs 730 days: auth, security, access and api-keys by default (audit.security_log_names), because security events are kept two years. Log names are stored trimmed and in lower case, so Auth and auth are one log on every engine. php artisan audit:prune deletes in two passes on created_at: rows outside the security logs past audit.retention_days, then security log rows past audit.security_retention_days. The provider schedules it daily at audit.prune.time (UTC), on one server and without overlapping itself, through the scheduler's cache lock: every scheduler host must use the same cache store, with locks and the same prefix, and the overlap lock lasts 24 hours, so a run still going after a day can meet the next one. A product that runs it itself sets audit.prune.schedule to false. Overlapping runs are safe anyway: the ids to delete are read from the write connection (never a replica that may lag) and each delete rechecks the cutoff.

A row under legal hold (retain_until, UTC, set by the product on stored rows) is skipped until the hold has passed; a hold only lengthens retention. See "Legal hold" in docs/reference-schema.md.

Spatie's activitylog:clean goes through the same two floors: the package sets activitylog.actions.clean_log to its own clean action, so activitylog:clean --days=1 (or a named log) never deletes a row younger than 365 days, or a security log row younger than 730. A product that keeps it in the schedule loses nothing; audit:prune alone is enough.

Deploy check

Run php artisan audit:check in every deploy, after migrate. It exits non-zero, naming the key, when the retention floors are invalid, when audit.prune.time is invalid while the package schedules the purge (audit.prune.schedule; a product that schedules audit:prune itself owns its time), or when the activity_log table (on the activity model's connection) lacks a column the package writes, purges or erases by, under the configured morph id names. The boot checks already stop the misconfigurations that would lose events (model, actions, timezone, production switches).

Querying

Activity::query()->causedBy($user), ->forSubject($model) and ->forOrganisation($organisationUuid) bind ids as strings. forOrganisation never returns rows without an organisation: those are for the instance super-admin, through an unscoped query the product guards. causedBy, forSubject and activitiesAsSubject() do not filter by organisation: a tenant page always adds forOrganisation().

Boot checks

The application does not boot when:

  • activitylog.activity_model does not extend Qiick\Audit\Models\Activity, activitylog.actions.log_activity does not extend Qiick\Audit\Actions\LogActivityAction (it writes the attribution), or activitylog.actions.clean_log does not extend Qiick\Audit\Actions\CleanActivityLogAction (it applies the retention floors);
  • app.timezone is not UTC;
  • in production, activitylog.enabled is not true or activitylog.buffer.enabled is not false (security events must not be turned off or lost by one env variable).

Serialised rows never carry the bigint id; timestamps are RFC 3339 UTC. The security checklist maps every design risk to its tests: docs/security-checklist.md. Adopting the package in a product: UPGRADING.md.

Threat model

Assets. The security event log every qiick product writes (who did what, through which credential, in which organisation), and the personal data those rows hold (names, emails, IP addresses, user agents).

Trust boundaries. Callers of the logging API (product code, often fed by user input) are untrusted for attribution: the package writes the reserved keys, the organisation and the credential itself. The product's resolvers (OrganisationResolverContract, AuditActorResolverContract) and the erasure orchestrator are trusted. The application's database credentials are trusted with the table.

Threat Control Test
Secrets reach the log secret floor: built-in names and parts, encrypted* / hashed casts, audit.sensitive_attributes; a model can add excludes, never remove these A1
Forged attribution (api_key_id, ip, actor_kind, organisation) reserved keys always carry server values; properties.organisation_id never sets the column A2, A3, A4
Cross-tenant reads forOrganisation() excludes rows of other and of no organisation A5
Internal ids leak public_id UUID v7; bigint id and key ids never serialised A6
Erasure misses rows or deletes evidence one pass over causer, subject and credential rows; rows scrubbed with a constant tombstone, never deleted; idempotent A7, A8, A14, E1–E14
The log is turned off or loses events boot fails in production with the log off or buffered A9
Log injection stored as is; the product escapes when rendering A10
Wrong time zone or 2038 overflow boot check on UTC; datetime, never TIMESTAMP; RFC 3339 Z export A13
Retention deletes early or never two floors in one purger used by every delete path; scheduled daily by the package; invalid floors fail before any delete retention tests
Concurrent writers corrupt erasure or purge row locks during erasure; purge deletes are idempotent and recheck the cutoff AnonymiserConcurrencyTest, PurgeConcurrencyTest

Out of scope, owned by the product.

  • Tamper evidence. Anyone holding the application's database credentials can change or delete rows; the table is not hash-chained (additive after 1.0). Products that need protected security logs (ASVS 5.0 V16.4) export audit.security_log_names rows to a separate system the application cannot modify (#24).
  • Free text the anonymiser cannot recognise, rows written after an erasure run, application logs, queues, replicas and backups ("Erasure perimeter").
  • Authorization of who may read the log, and escaping when it is rendered.
  • Externa 1.x's backfill and dual write (A12).

How each standard the design names is met: docs/standards-traceability.md.

Deprecation policy

This package follows Semantic Versioning (SemVer):

  • Deprecation in minor releases: When a public API (class, method, interface, config key, or environment variable) is deprecated, it is marked with @deprecated docblocks, documented in CHANGELOG.md and UPGRADING.md, and triggers a runtime notice or warning where appropriate. The deprecated feature remains functional and supported for at least one minor release.
  • Removal in major releases only: Deprecated APIs are never removed within the same major version (0.x or 1.x). Breaking removals occur exclusively at the next major release boundary (e.g. 2.0.0).
  • Pre-1.0 stability: In 0.x, breaking changes are documented in UPGRADING.md before each tagged release. Once 1.0.0 ships, public contracts and migrations are frozen and follow strict SemVer forward compatibility.

Security

Private vulnerability reporting: see SECURITY.md.

License

MIT. See LICENSE.

Alternatives to qiick/laravel-audit

mradder/filament-logger

Audit logging, activity tracking, exports, alerts, and dashboards for Filament a...

68,368 26
jorijn/laravel-security-checker

Checks your composer.lock against the Packagist security advisories database fro...

1,958,007 202
asignua/filament-activity-log-plus

An audit trail for Filament 5 on top of spatie/laravel-activitylog 5 that record...

8,467 0
exin/enlightn

Fork of Enlightn with Laravel 12 support

25,940
laboiteacode/filament-activity-timeline

The semantic activity timeline for Filament. Turn technical activity logs into c...

6,285 10

Version History

Pre-releases (2)
Version Released PHP Laravel License
v0.1.0-beta.2 ^8.4 ^12.0 || ^13.0 MIT
v0.1.0-beta.1 ^8.4 ^12.0 || ^13.0 MIT