Quick start
Four steps from a fresh install to a working re-consent gate.
1. Write your texts
Author them as Markdown with frontmatter at resources/legal/{type}/{locale}.md:
---
version: "1.0.0"
title: Nutzungsbedingungen
ui_wording: Ich akzeptiere die Nutzungsbedingungen.
---
# Nutzungsbedingungen
…
version drives the ledger and decides what counts as a major change. Two optional keys,
announce_at and enforce_at (or effective_at), let the text itself carry its schedule —
the publish flags below override them. How a change is classified is never taken from the
file: that is a decision you make per publish, at the command line.
2. Publish a version
Publishing freezes the current source into the ledger, and you must classify the change:
php artisan legal-consent:publish terms de --active
An initial version takes effect at once — there is nothing to give notice of yet. A later material change is a different act: it must be announced ahead of its effective date, with the advance period its regime requires. See Notice modes.
--active is what gives step 4 something to enforce: only an active re-consent version gates.
Filling a whole registry at once is the other case, and Installation uses
--editorial for it — nobody has agreed to anything yet, so nothing is being announced.
3. Give any model a consent ledger
use Illuminate\Foundation\Auth\User as Authenticatable;
use Pushery\LegalConsent\Concerns\HasLegalConsents;
class User extends Authenticatable
{
use HasLegalConsents;
}
4. Enforce re-consent
Add the middleware to your authenticated routes:
// bootstrap/app.php
->withMiddleware(function (Middleware $middleware): void {
$middleware->appendToGroup('web', \Pushery\LegalConsent\Http\Middleware\EnsureLegalConsent::class);
})
It redirects to your legal.consent route (or returns 409 legal_consent_required
for JSON) when a mandatory document has an outstanding new major version.
Next
- Recording consent — how acceptance actually reaches the ledger.
- User interface — the screens to render at that
legal.consentroute.