Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Model Flags Laravel Package

spatie/laravel-model-flags

Add lightweight flags to Eloquent models without extra columns. Set and check flags, then query with handy flagged/notFlagged scopes. Ideal for idempotent, restartable jobs and commands (e.g., send a mail only once per user).

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature Development: Enables rapid implementation of stateful workflows (e.g., user onboarding, multi-step processes, or background jobs) without schema migrations or complex database design.
  • Idempotency: Critical for reliable background jobs (e.g., cron jobs, queues) where retries must avoid duplicate operations (e.g., sending emails, processing payments).
  • Roadmap Efficiency: Reduces technical debt by avoiding premature database schema changes for temporary or experimental features (e.g., A/B testing flags, feature toggles).
  • Build vs. Buy: Buy—avoids reinventing flag management logic (e.g., JSON columns, soft-deletes, or custom traits) while maintaining Laravel’s conventions.
  • Use Cases:
    • Process Tracking: Mark users as "verified," "notified," or "processed" without additional columns.
    • Audit Trails: Lightweight logging of state changes (e.g., "flagged_for_deletion").
    • Feature Flags: Dynamic toggles for features (though dedicated packages like spatie/laravel-feature-flags may be better for production-grade toggles).
    • Data Migration: Safely resume interrupted batch operations (e.g., User::notFlagged('processed')->update(...)).

When to Consider This Package

  • Adopt When:
    • You need temporary or dynamic flags for Eloquent models without migrations.
    • Your workflows require idempotency (e.g., retries, cancellations).
    • You’re prototyping stateful features (e.g., multi-step forms, background jobs).
    • Your team prefers Laravel-native solutions over raw JSON columns or custom logic.
  • Look Elsewhere If:
    • You need persistent, queryable metadata (use spatie/laravel-activitylog or JSON columns).
    • Flags require complex permissions/roles (use spatie/laravel-permission).
    • You need feature flags with analytics (use spatie/laravel-feature-flags or tightenco/ziggy).
    • Performance is critical (flags use a flags column; consider indexed columns for high-scale apps).
    • You’re managing many flags per model (e.g., >100; evaluate JSON or dedicated tables).

How to Pitch It (Stakeholders)

For Executives: "This package lets us add ‘tags’ or ‘states’ to user records (e.g., ‘email_sent’, ‘verified’) without writing migrations or complex code. It’s perfect for making our background jobs and workflows reliable and restartable—like pausing a bulk email send and resuming later without duplicates. Think of it as ‘sticky notes’ for our database records, but automated. It’s lightweight, maintained by a trusted Laravel vendor, and saves dev time on boilerplate."

For Engineers: *"Spatie’s laravel-model-flags gives us a zero-migration way to add flags to Eloquent models using a flags column (stored as a JSON array). Key benefits:

  • Idempotency: Safe retries for jobs (e.g., User::notFlagged('processed')->each(...)).
  • Scopes: Query models by flag (User::flagged('active')).
  • No Schema Changes: Avoids migrations for temporary/experimental features.
  • Laravel Integration: Works seamlessly with Eloquent, Artisan, and queues. Tradeoff: Flags are stored in JSON; not ideal for high-scale apps or complex queries. Use for process states, lightweight toggles, or prototyping."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport