spatie/laravel-model-flags
A Laravel trait that adds flags to Eloquent models without migrations, plus scopes to query flagged models. Useful for tracking process state and building idempotent, restartable code like Artisan commands.
flags table plus trait is roughly a half-day of engineering plus ongoing migration debt for each new boolean. With 454 stars, MIT license, an actively maintained Spatie release train (Laravel 11/12/13 support, enum support, lastFlaggedAt, array unflagging), and zero infrastructure cost, this is a clear "buy" — the build decision is only defensible if flags must live in the same table as domain state for query performance or reporting.lastFlaggedAt() gives lightweight "when did this last happen" answers for support and CS without a full event/audit pipeline — useful for triage tooling and customer-facing status.flagged / notFlagged) to drive batch selection; you're on Laravel and already accepting Spatie as a trusted vendor.flags table adds a join and index pressure versus a native boolean column; when you need rich metadata, actor, or reason per flag (this stores a name and timestamps only); when you need flag evaluation for A/B assignment or percentage rollouts (use a feature-flag service or LaunchDarkly-style tool, not this); when you need historical/append-only audit trails of every state change; or when you require strict type safety across many flags — stringly-typed flag names invite typos, so prefer enums (supported) and enforce naming conventions in code review.flags polymorphic table shared across all models, so high-volume flag tables become a shared scaling concern; flag cleanup on model delete is handled, but stale flag names across the codebase are not — you'll want a documented registry of allowed flags. Low dependent count (0) reflects that it's a small utility rather than a widely-forked ecosystem piece; treat vendor-abandonment risk as low given Spatie's track record but pin the version and be ready to vendor the trait (it's ~200 lines).To executives: This is a small, free, MIT-licensed utility from Spatie that lets us record per-record state — "this customer got the email", "this account finished migration" — without database changes for each new case. It directly reduces the cost and risk of running large customer-facing batches, because those jobs become safely restartable: if a job dies halfway, we re-run it and only the remaining customers are touched. That means fewer duplicate emails, fewer double-credits, and less engineering time building one-off tracking. Expected effort is hours, not weeks, and there's no new infrastructure or vendor contract.
To engineering: Add the package, publish the migration, and use HasFlags on models that need it. You get flag(), hasFlag(), unflag(), flagNames(), lastFlaggedAt(), and flagged/notFlagged scopes backed by a single polymorphic flags table. Use enums for flag names to get some type safety; keep a registry of flag names to prevent drift. It's not a feature-flag system and not a substitute for real domain columns on high-traffic query paths — treat it as operational bookkeeping for idempotent jobs and lightweight lifecycle markers. Active maintenance is confirmed through Laravel 13, so keep it current and pin the minor version.
How can I help you explore Laravel packages today?