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

An approver can hand their authority to another model for a window. While the delegation is active, the delegate’s decisions count as the delegator — the approval records both the delegator (as actor) and the delegate (as decided_by):

use Carbon\CarbonImmutable;
use RoundlyConsulting\Approvals\Facades\Approvals;

Approvals::delegations($manager)->to($assistant)->until(CarbonImmutable::now()->addWeek())->grant();
// or ->from($start), ->for($seconds) (measured from the start), or no window at all

$approval = Approvals::for($release)->as($assistant)->approve();   // counts as $manager
$approval->wasDelegated();                   // true
$approval->actor;                            // $manager
$approval->decidedBy;                        // $assistant

Approvals::for($release)->as($assistant)->cancel();   // the delegate can withdraw what it decided for $manager — while the delegation is in force

Setting the window

Approvals::delegations($delegator)->to($delegate) collects the window with from(), until() or for(); nothing is written until grant(), which saves the ApprovalDelegation and fires ApprovalDelegated once, with the final window. Without a window the delegation is open-ended. The trait’s delegateApprovalsTo() grants at once:

use Carbon\CarbonImmutable;
use RoundlyConsulting\Approvals\Facades\Approvals;

// A fixed leave window.
Approvals::delegations($manager)->to($assistant)
    ->from(CarbonImmutable::parse('2026-08-03'))
    ->until(CarbonImmutable::parse('2026-08-14'))
    ->grant();   // ApprovalDelegation

// One hour from now.
$delegation = Approvals::delegations($manager)->to($assistant)->for(3600)->grant();

// GivesApprovals shorthand — grants at once and returns the ApprovalDelegation
$manager->delegateApprovalsTo($assistant);                                        // open-ended
$manager->delegateApprovalsTo($assistant, until: CarbonImmutable::now()->addWeek());

Revoking and listing

Approvals::delegations($manager)->revoke();             // revoke all — active and scheduled; returns the count
Approvals::delegations($manager)->revoke($assistant);   // revoke one delegate
Approvals::delegations($manager)->active();             // Collection<ApprovalDelegation> in force now, newest first
Approvals::delegationFor($assistant);                   // ?ApprovalDelegation the assistant acts under now

$manager->revokeApprovalDelegation($assistant);         // GivesApprovals shorthand
$manager->approvalDelegations;                          // every delegation handed out

$delegation->isActiveAt();                              // bool — started, not ended, not revoked
$delegation->isActiveAt(CarbonImmutable::parse('2026-08-10'));
$delegation->revoke();                                  // sets revoked_at on this one model

revoke() revokes the delegator’s delegations that are in force or scheduled to start later — or only those to one delegate — sets revoked_at, fires ApprovalDelegationRevoked per revocation and returns the count. It never touches another delegator’s delegations. Calling revoke() on a single ApprovalDelegation model sets revoked_at without firing the event.

Revocation is a kill switch: it ends the delegation at once and for every moment, so isActiveAt() and Approvals::delegationFor() report no delegation even for a moment before revoked_at. revoke($at) only records when it happened (now when omitted); a moment in the future throws InvalidDelegationException, because a revocation can’t be scheduled — give the delegation an end with until() instead.

Rules of attribution

  • A delegation is in force when it is not revoked, has started (starts_at empty or past) and has not ended (ends_at empty or still ahead).
  • On a request that names its approvers, a delegate may decide for a named delegator, and a model that is itself a named approver always decides as itself, even when it also stands in for someone.
  • Elsewhere, every decision by the delegate counts as the delegator; when several delegations apply, the most recently created one wins. The weight is resolved from the delegator.
  • On a round, only the delegations that count in its scope apply — see Scoped delegations below.
  • The authorization gate checks the acting delegate, before the decision is re-attributed.
  • While the delegation is in force, the delegate can withdraw what it decided for the delegator with cancel() or cancelApproval(). Once it is revoked or has ended, the delegate gets null and those decisions keep counting — only the delegator can withdraw them.
  • ask() is addressed to the asked model itself, never to whoever it stands in for.

Validation

grant() validates before writing: delegating to yourself, a window that ends before it starts and, since 2.4.0, a scope that isn’t saved all throw InvalidDelegationException and leave no row behind:

use Carbon\CarbonImmutable;
use RoundlyConsulting\Approvals\Facades\Approvals;

Approvals::delegations($manager)->to($assistant)
    ->from(CarbonImmutable::parse('2026-08-14'))
    ->until(CarbonImmutable::parse('2026-08-03'))   // ends before it starts
    ->grant();   // throws InvalidDelegationException — no row is written

Approvals::delegations($manager)->to($manager)->grant();   // throws InvalidDelegationException — self-delegation

Scoped delegations

Since 2.4.0 a delegation can be limited to one context — a team, a tenant, a company — so a person who approves in two companies can hand off approvals in one without handing them off in the other:

use RoundlyConsulting\Approvals\Facades\Approvals;

// Anna approves in two companies; Ben covers her in company A only.
Approvals::delegations($anna)->to($ben)->within($companyA)->grant();
$anna->delegateApprovalsTo($ben, scope: $companyA);   // GivesApprovals shorthand

The scope is a nullable morph (scope_type, scope_id) on approval_delegations, added by migration 0010. A delegation without one keeps counting everywhere. The package learns which context a round belongs to from delegations.scope_resolver, a class implementing ResolvesDelegationScope:

use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Approvals\Interfaces\ResolvesDelegationScope;
use RoundlyConsulting\Approvals\Models\ApprovalRequest;

final class TeamOfRound implements ResolvesDelegationScope
{
    public function scopeOf(ApprovalRequest $round): ?Model
    {
        return $round->subject?->team;   // null = a round in no context
    }
}

// config/approvals.php
'delegations' => ['scope_resolver' => TeamOfRound::class],

With a resolver configured, a round counts the delegations with no scope plus those limited to exactly the scope it returns; when it returns null — a round in no context — only the unscoped ones count. That applies everywhere a delegate is honoured:

  • Deciding — approve, reject, toggle. A delegate out of scope on a round with named approvers is refused with UnauthorizedApprovalException; on a round without names it decides as itself.
  • Withdrawing — a delegate can cancel what it decided for the delegator only while a delegation that counts in the round is in force.
  • recheckThreshold() — an approver the gate refuses stays available only through an in-scope delegate.

Without a resolver nothing changes: every delegation counts in every round, scoped or not, and a decision outside any round always counts every delegation. To ask directly, delegationFor() and active() take an optional scope — only delegations that count within it; without one they return every delegation, as before:

Approvals::delegationFor($ben, scope: $companyA);          // ?ApprovalDelegation that counts in company A
Approvals::delegations($anna)->active(scope: $companyA);   // only those that count in company A

ApprovalDelegation::query()->within($companyA)->get();     // unscoped + limited to company A
ApprovalDelegation::query()->within(null)->get();          // only the unscoped ones

$delegation->scope;                       // the context, null when it counts everywhere
$delegation->isScoped();                  // bool
$delegation->countsWithin($companyA);     // bool

The factory has a scoped($team) state. The scope columns are read and written only once a delegation is scoped or a resolver is configured, so a host that hasn’t run 0010 yet keeps delegating.

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.