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

Both enums are string-backed:

EnumCases (value)
ApprovalStatusPending (pending), Approved (approved), Rejected (rejected), Cancelled (cancelled), Expired (expired)
ApprovalRuleUnanimous (unanimous), Quorum (quorum), Any (any), Weighted (weighted)

Domain methods

use RoundlyConsulting\Approvals\Enums\ApprovalRule;
use RoundlyConsulting\Approvals\Enums\ApprovalStatus;

ApprovalStatus::Pending->isPending();     // true
ApprovalStatus::Rejected->isDecided();    // true — approved or rejected
ApprovalStatus::Cancelled->isFinal();     // true — anything but pending
ApprovalStatus::Rejected->isLive();       // true — pending, approved or rejected: still the actor's live decision
ApprovalStatus::Approved->canTransitionTo(ApprovalStatus::Cancelled);   // true

ApprovalRule::Quorum->isWeighted();       // true — Quorum and Weighted resolve on summed weight
ApprovalRule::Any->isWeighted();          // false

Labels, options and validation

Both enums use the shared Helpers trait from enums-for-laravel, so they expose the full helper surface on top of their domain methods — with no lang file to maintain:

ApprovalStatus::values()->all();   // ['pending', 'approved', 'rejected', 'cancelled', 'expired']
ApprovalStatus::labels()->all();   // ['Pending', 'Approved', 'Rejected', 'Cancelled', 'Expired']
ApprovalStatus::options();         // Collection of {value, label, name} option DTOs for selects
ApprovalStatus::validationRule();  // 'in:pending,approved,rejected,cancelled,expired'
ApprovalStatus::tryFromName('Approved');   // ApprovalStatus::Approved

ApprovalStatus::Approved->readable();      // 'Approved' (translated, headline-cased)
ApprovalStatus::Approved->isIn([ApprovalStatus::Approved, ApprovalStatus::Rejected]);   // true

ApprovalRule::options();              // a ready-made rule picker
ApprovalRule::validationRule();       // 'in:unanimous,quorum,any,weighted'
ApprovalRule::Weighted->readable();   // 'Weighted'

Drop validationRule() straight into request rules and options() into a select or a JSON payload — both stay in sync with the cases automatically:

$request->validate([
    'status' => ['required', ApprovalStatus::validationRule()],
    'rule' => ['required', ApprovalRule::validationRule()],
]);

Also available: names(), toOptions(), toArray(), collect(), count(), random(), fromName(), fromLabel() / tryFromLabel(), hasName() / hasValue(), label(), is() / isNot() / isNotIn() and the whenIs…() callbacks.

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.