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

Approval rules

Pick a rule — and a quorum, where relevant — on the builder:

use RoundlyConsulting\Approvals\Enums\ApprovalRule;

// Any 2 of 3 managers (first-past-the-post quorum):
Requests::make()
    ->requireApprovalsFrom([$a, $b, $c])
    ->rule(ApprovalRule::Quorum)
    ->quorum(2)
    ->create();

// First approver wins:
Requests::make()->requireApprovalsFrom([$a, $b])->rule(ApprovalRule::Any)->create();

// Weighted — a senior approver (ProvidesApprovalWeight) clears the threshold alone:
Requests::make()
    ->requireApprovalsFrom([$senior, $junior])
    ->rule(ApprovalRule::Weighted)
    ->quorum(3)
    ->create();
RuleResolves to Approved when
ApprovalRule::UnanimousEvery declared approver has approved. The default.
ApprovalRule::Quorumquorum() approvals are in — before every approver has decided.
ApprovalRule::AnyThe first approval arrives.
ApprovalRule::WeightedThe summed weight of approvals reaches quorum(). Each approver weighs 1 unless it implements ProvidesApprovalWeight.

Weighted approvers

For the weighted rule, implement ProvidesApprovalWeight on the actor. The approvable passed in is the request being decided, so the weight can depend on its type or meta:

use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Approvals\Interfaces\GivesApprovalsInterface;
use RoundlyConsulting\Approvals\Interfaces\ProvidesApprovalWeight;
use RoundlyConsulting\Approvals\Traits\GivesApprovals;

class User extends Model implements GivesApprovalsInterface, ProvidesApprovalWeight
{
    use GivesApprovals;

    // $approvable is the request being decided — weigh by role, amount, type…
    public function approvalWeight(?Model $approvable = null): int
    {
        return $this->is_director ? 3 : 1;
    }
}

With quorum(3), a director weighing 3 clears the threshold alone; three regular approvers weighing 1 each reach it together.

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.