protonemedia/laravel-eloquent-where-not
Adds whereNot and orWhereNot methods to Laravel Eloquent, letting you negate simple conditions, nested closures, and relationships cleanly. A small, expressive package for readable inverse WHERE clauses without raw SQL or awkward operator flipping.
active(), published(), withinBudget()) and its negation live in two places, they drift. Any whereNot(fn ($q) => $q->scope()) pattern makes the negation derive from the source of truth, which shrinks the surface area for "the filter says one thing, the exclusion says another" bugs in admin panels, reports, and export jobs.whereNot/orWhereNot became available. The package's compatibility update therefore closes the gap it was meant to fill: any app new enough to run 1.2.0 is new enough to use the framework primitive. Treat this as an input to an "adopt the native convention / drop the polyfill" roadmap item, not as a dependency decision.Consider the concept (strongly) when:
whereNot does not fully cover ergonomically (native support targets grouped constraints, not named-scope inversion).app/Support under the MIT license with attribution — this eliminates the archived-dependency risk entirely and is the only form in which 1.2.0 is relevant to us.NOT (col = 'x') is not col != 'x' when col is NULL) plus the OR-precedence trap when a scope mixes where and orWhere.Look elsewhere (or write your own ten lines) when:
whereNot/orWhereNot first; you may already own 70–100% of this. The release narrows the package's addressable audience to people who already have the alternative.orWhere, joins, whereHas with nested or, or aggregates. Inversion of these is not mechanically safe, and a "clever" one-liner here is a correctness incident waiting to happen.Adoption criteria (all should hold): MIT attribution retained if vendored · no archived package added to composer.json (1.2.0 does not change this) · inversion limited to simple AND-only scopes · unit tests asserting positive and negative result sets are complementary on fixtures that include NULLs · a documented escape hatch back to explicit scopes.
To executives (one paragraph): This is a small open-source utility that lets our code express "everything except what this existing filter matches" without rewriting the filter backwards. The business value is fewer reporting and segmentation bugs caused by a filter and its exclusion drifting apart, plus slightly faster delivery on include/exclude features. It is free (MIT), tiny, and unmaintained; the new 1.2.0 release only adds Laravel 9 support — a version that already ships the framework equivalent — so our recommendation is unchanged: copy the relevant snippet into our own codebase rather than take on a dependency. Cost is a few hours of an engineer's time; risk is near zero; upside is modest and localized.
To engineering (the honest version): Protonemedia's laravel-eloquent-where-not inverts an Eloquent scope or query constraint so negation derives from a single source of truth. 1.2.0 adds Laravel 9 support and nothing else — no API changes, no fixes, no deprecations — so it does not alter the verdict: do not add it to composer.json. It remains archived, has 28 stars and no dependents, and its compatibility ceiling now sits at a version that already provides native whereNot. Instead: (1) verify whether native whereNot covers the case; (2) if the gap is specifically scope inversion, vendor the trait into app/Support with MIT attribution and a short docblock; (3) restrict its use to AND-only scopes and add complementary-set tests with NULL fixtures; (4) for scopes containing orWhere, joins, or whereHas, write an explicit negative scope and get it reviewed. Ship it behind a convention, not a dependency.
To security/compliance, if asked: no data leaves the application, no runtime service dependency, no network calls; the only artifacts are source lines copied under a permissive license. The 1.2.0 release changes only a Composer version constraint, so there are no new transitive dependencies to review. The residual risk is logical, not operational — hence the guardrails on OR and NULL semantics rather than on provenance.
How can I help you explore Laravel packages today?