NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

Each transition dispatches an event carrying the relevant model. All events live in RoundlyConsulting\Approvals\Events and expose their payload as public properties:

EventPayloadFired when
ApprovalRequestedapprovala pending decision is asked for (ask())
ApprovalApprovedapprovala decision is approved
ApprovalRejectedapprovala decision is rejected
ApprovalCancelledapprovala decision is withdrawn — by cancel(), by a toggle-off, or an outstanding ask retired because its request resolved, its stage settled, your app closed the round (close()) or dropped the asked approver from the round (replaceApprovers(), replaceFlatApprovers())
ApprovalExpiredapprovala pending or approved decision lapses
ApprovalRequestResolvedrequesta request reaches approved, rejected or expired — or your app closes it: close(), voidIfChanged() or a closing recheckThreshold(); once, after its outstanding asks are retired
ApprovalToggledactor, entity, hasBeenApprovedtoggle() / toggleApproval() runs
ApprovalRoundOpenedround, approvers, stagea round opens — flat or staged, from request() or workflow(); once per round, after the surrounding transaction commits. approvers are the models asked to decide now (the round’s, or the first stage’s; empty: anyone may decide), stage the first stage or null; subject() returns the subject. Fires before the first ApprovalStageOpened, never on a stage advance or a replacement of approvers. Since 2.4.0
ApprovalStageOpenedstagea staged request opens a stage — or your app hands the open stage to other approvers (replaceApprovers()); the stage then carries the new approvers
ApprovalStageClearedstagea stage clears as approved
ApprovalDelegateddelegationan approver delegates authority
ApprovalDelegationRevokeddelegationa delegation is revoked
ApprovalApproversReplacedrequest, stage, added, removedyour app replaced a round’s approvers — a stage’s (replaceApprovers(), before ApprovalStageOpened) or a flat round’s (replaceFlatApprovers(), stage null); added and removed are list<NamedApprover>
ApprovalRequestVoidedrequest, openedWith, currenta round whose subject fingerprint changed was voided — by voidIfChanged() or a decision under fingerprint.on_change void — after ApprovalRequestResolved and ApprovalStatusChanged; carries the stored and the current fingerprint
ApprovalThresholdUnreachableverdictrecheckThreshold($closeAs) closed a round that can no longer reach its threshold, after ApprovalRequestResolved and ApprovalStatusChanged; the ThresholdVerdict’s closedAs is Cancelled or Rejected
ApprovalStatusChangedsubject, from, to, actorumbrella — every status transition of a decision or request, alongside the granular event

When a round opens

Since 2.4.0 a round opening fires ApprovalRoundOpened once, and a staged round then fires ApprovalStageOpened for its first stage. The round and its stages are written in one transaction, and both events wait for the surrounding commit when a transaction is open, so a rolled-back open fires neither. Listen to ApprovalRoundOpened to act once per round — one notification to every approver, a timer, an audit entry — without telling flat and staged rounds apart:

use Illuminate\Support\Facades\Event;
use RoundlyConsulting\Approvals\Events\ApprovalRoundOpened;

Event::listen(function (ApprovalRoundOpened $event): void {
    $event->round;       // the ApprovalRequest
    $event->subject();   // e.g. the Invoice
    $event->approvers;   // list<Model> asked to decide now — empty: anyone may decide
    $event->stage;       // the first ApprovalRequestStage, null for a flat round
});

The umbrella event

Subscribe to ApprovalStatusChanged once to observe all transitions: a decision approved, rejected, withdrawn — including by a toggle or by a change of mind that supersedes it — or expired, an outstanding ask retired when its round closes, and a request resolved, expired or closed by your app. It carries the subject (the Approval or ApprovalRequest that changed), the from and to ApprovalStatus, and the actor when one is known — null for a resolved request or a retired ask:

use RoundlyConsulting\Approvals\Events\ApprovalStatusChanged;

class AuditApprovalChanges
{
    public function handle(ApprovalStatusChanged $event): void
    {
        // $event->from, $event->to, $event->subject, $event->actor
        logger()->info("approval moved {$event->from->value} -> {$event->to->value}");
    }
}

Granular listeners

use Illuminate\Support\Facades\Event;
use RoundlyConsulting\Approvals\Events\ApprovalApproved;
use RoundlyConsulting\Approvals\Events\ApprovalRequestResolved;

Event::listen(function (ApprovalApproved $event): void {
    $approval = $event->approval;   // the Approval model
});

Event::listen(function (ApprovalRequestResolved $event): void {
    $request = $event->request;     // approved, rejected or expired — see $request->status
    $subject = $request->subject;   // e.g. the Release
});

An ask() creates a pending decision rather than changing one, so it fires only ApprovalRequested. Stage changes, delegation and replacements of approvers (ApprovalApproversReplaced) also fire only their own events — not the umbrella one.

When a round closes

Whether its decisions resolve it, it lapses or your app closes it, a round’s events come in one order: ApprovalCancelled and ApprovalStatusChanged for each retired ask, then ApprovalRequestResolved, then ApprovalStatusChanged for the request. A listener of the resolution never sees an ask still waiting on the round. A void (voidIfChanged()) and a closing threshold re-check close the round the same way, then fire ApprovalRequestVoided or ApprovalThresholdUnreachable last.

Confirmation events

Since 2.3.0, single-use confirmations have their own family. A confirmation is not an approval or a request, so these never fire ApprovalStatusChanged:

EventPayloadFired when
ApprovalConfirmationRequestedconfirmationa single-use confirmation was asked for (confirmation()->request())
ApprovalConfirmationConfirmedconfirmation, personits person confirmed it — once, even under concurrent confirms
ApprovalConfirmationDeclinedconfirmation, personits person declined it; the reason is on $confirmation->reason
ApprovalConfirmationExpiredconfirmationa pending confirmation lapsed — by the sweep, or by a confirm or decline refused as expired; once per confirmation

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.