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 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

Automatically convert your Eloquent scopes to boolean check methods.

Frequently asked questions about Laravel Scope Checks
What does beyondcode/laravel-scope-checks actually do?
It is a small developer-ergonomics trait for Eloquent models that uses reflection over scope methods to provide boolean helpers for checking whether a scope exists or applies before you chain it. It is not a domain capability or a query builder replacement; it is a coding pattern with a reference implementation. The package description and some technical assessments describe slightly different behavior, so read the src directory before relying on it.
How do I install beyondcode/laravel-scope-checks?
Install it with composer require beyondcode/laravel-scope-checks, then add the package trait to any Eloquent model where you want the checks. It is MIT licensed and mechanically simple to wire in. Note that the upstream repository is archived and the last release is from 2020, so installation is easy but long-term maintenance becomes your responsibility.
Which Laravel and PHP versions does laravel-scope-checks support?
There is no evidence the package was validated against Laravel 9, 10, or 11 or PHP 8 and above; the last release dates to February 2020. Treat version support as unverified and run it against your CI matrix and representative models before adopting it. For new work, reproducing the pattern internally is lower risk.
Is beyondcode/laravel-scope-checks safe to use in production?
The dominant production risk is silent incorrectness rather than an outage: a boolean check can return the wrong answer inside a UI conditional or eligibility check without throwing an exception. Combined with archived upstream maintenance and unverified framework compatibility, the risk is high for critical paths. Use it only for low-volume internal checks, or internalize the pattern with tests.
Does checking a scope with laravel-scope-checks hit the database?
Some usages issue a database query per check, which can produce N+1 queries in loops, serializers, and Blade partials. The shipped behavior is ambiguous between an assertion helper and generated per-record predicates, and those have different query profiles. Inspect the source and profile your actual call sites before using checks in hot paths.
How does laravel-scope-checks handle parameterized scopes, global scopes, and soft deletes?
The package is described as having limitations around zero-argument scopes and unclear handling of global scopes and soft deletes. Non-filtering scopes such as orderBy or with may produce misleading check results because they do not filter records. Test these cases explicitly on your own models before depending on the package.
What happens if I rename or remove a scope used by laravel-scope-checks?
A renamed or removed scope should produce a loud error; a silent false is the dangerous outcome. Because the implementation uses reflection over scope methods, behavior depends on how the check resolves missing names. Verify this with a failing test before depending on it in conditionals.
Can I reproduce laravel-scope-checks myself instead of using the package?
Yes. The implementation is roughly 40 lines: one trait plus reflection over scope-prefixed methods. Internalizing it takes about an afternoon and gives you full ownership, no archived dependency, and a place to add parity tests. For new product work this is the defensible path.
When should I avoid using laravel-scope-checks?
Avoid it in layered architectures with repository or query-object boundaries, read/write-separated models, or any contract where a boolean method silently issuing a query is a violation. Do not use it for authorization, billing, entitlements, compliance, or regulatory status; those belong in Policies, Gates, and explicit domain services. Skip it for non-Laravel PHP or teams already standardizing on query objects.
What are alternatives to beyondcode/laravel-scope-checks in Laravel?
Prefer native Eloquent tools such as withExists(), exists subselects, and attribute casting when they express the check clearly. Use Policies and Gates for authorization and explicit domain services for business status. You can also write your own small trait or query-object method so the vocabulary of active, published, and verified has one named definition.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo