Weave 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 Scope Checks Laravel Package

beyondcode/laravel-scope-checks

Laravel Scope Checks offers simple helpers for verifying that an Eloquent model has a given query scope before you apply it. It helps keep dynamic query building safe and predictable, with readable checks that are easy to use and test.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

Build vs. buy — the answer is build. This package is a ~40-line convenience shim over Eloquent local scopes: it reflects on scope* methods and exposes matching boolean checks (scopeActive → isActive()) for a single hydrated record. It has 77 stars, zero dependents, an archived upstream, and a last release of February 2020. The product call is not "should we adopt this?" but "is the pattern worth an afternoon of internal engineering?" Budget the afternoon, own the code, skip the dependency.

Status vocabulary consistency. The real decision this informs is whether the product has one named definition of "active," "published," or "verified" — or whether that logic is re-typed inline across controllers, Blade templates, and API resources. Use it to push engineering toward consistent status semantics in legacy CRUD/admin areas, not to justify a Composer package.

Scoping decisions it supports: single-record presentation logic (badges, show/hide blocks, admin tables), legacy CRUD cleanup, and de-duplicating boolean status logic in an older Laravel app.

Scoping decisions it must not touch: authorization, billing, entitlements, compliance or regulatory status — anywhere a silently wrong boolean is worse than a hard failure. Those belong in Policies/Gates and explicit domain services, not generated predicates.

Roadmap impact: effectively zero. Nothing here is customer-facing. It belongs inside a story that already requires status consistency (a dashboard or admin rework), never as a roadmap line of its own. The only roadmap artifact worth producing is a decision gate: internalize the pattern, or reject it and hand-write the one or two checks we actually need.

A blocking ambiguity to resolve before funding anything. The sources disagree about what the package actually is. The description frames it as a runtime guard that asserts required scopes were applied to a query; the technical assessments describe generated per-record boolean methods. Those are different products with different risk profiles — a test-time assertion is cheap and safe, a per-record predicate that issues a query is not. Do not write a story until engineering reads src/ and confirms the shipped behavior.

Prioritization signal: modern Laravel (withExists(), attribute casting, exists subselects) already covers most of this ground natively. Confirm the team isn't solving it already — a "no" here is a legitimate, cheap outcome.

When to Consider This Package

Consider it when:

  • You maintain a legacy Laravel app (Laravel 6/7 era) with many zero-argument Eloquent scopes and genuinely repeated status logic, and the team accepts a frozen, unmaintained dependency.
  • The checks are internal, non-critical, and low-volume — admin dashboards, status badges, Blade conditionals — never money, access, or compliance.
  • You are evaluating it as a reference pattern for an in-house trait, in which case the archived upstream is irrelevant and you only borrow the idea.
  • You have a short, time-boxed spike budget and representative models with inline equivalents to write parity tests against.

Look elsewhere when:

  • You are on Laravel 9/10/11+ or PHP 8+ and need patching, security updates, or an upgrade path.
  • Checks would run inside loops, serializers, or paginated resources, where a per-call query becomes an N+1 problem.
  • The boolean governs authorization, billing, entitlements, or regulatory status.
  • You need vendor support or broad adoption — archived status and zero dependents disqualify it for new product work.
  • You only need one or two checks. Write them by hand.

Decision gate before any funding: inventory the scopes and call sites that would use it, spike it on a branch pinned to a tag with parity tests, and measure query counts around representative loops and API resources. If the value doesn't hold, close the ticket with a short engineering note — that is a successful outcome, not a failed one.

How to Pitch It (Stakeholders)

To executives: This is a small developer convenience for making status checks consistent in legacy Laravel code — not a strategic capability. The project is archived, last shipped in 2020, has minimal adoption and no dependents, and carries no upgrade path. Recommendation: do not add it as a production dependency. If the pattern proves useful, engineering can reimplement it internally in a day or two under our own ownership. Cost is negligible, roadmap impact is zero, and the main risk — an unmaintained dependency embedded in production logic — is better avoided than managed. The realistic downside isn't an outage; it's a wrong answer in a UI conditional that nobody notices.

To engineering: The package reflects scope* methods on a model and exposes matching boolean checks answering "does this record satisfy the scope." Useful for single-record presentation logic and feature tests. Caveats to weigh: archived and predating Laravel 8; zero-argument scopes only; each check likely issues a database query, so it must never be appended as an accessor on a paginated resource or called inside @foreach; naming collisions override hand-written methods; and non-filtering scopes (orderBy, with) produce misleading booleans. The documentation is also internally inconsistent about whether this is an assertion helper or a predicate method — resolve that first by reading the source. Treat it as a pattern, not a dependency: run a time-boxed spike pinned to a tag, write parity tests against the inline queries it replaces, check soft deletes, unsaved models, global scopes, and parameterized scopes, then vendor a small trait under our namespace with a named owner. Keep business rules in explicit services and policies, not in generated booleans. Design any internal version so a scope rename fails loudly rather than returning a plausible false — fail closed, never silent.

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.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core