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 Local Class Scope Laravel Package

mpyw/laravel-local-class-scope

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature Development: Enables cleaner, reusable query scopes for Eloquent models, reducing boilerplate in complex query logic (e.g., filtering by status, date ranges, or custom business rules).
  • Developer Experience (DX): Supports a build vs. buy decision by offering a lightweight, maintainable alternative to custom scope implementations, especially for teams already using Laravel’s global scopes.
  • Roadmap Prioritization: Aligns with Laravel’s proposed local query scopes, reducing technical debt if the feature is later natively adopted.
  • Use Cases:
    • Dynamic filtering: Replace hardcoded where() clauses in controllers with reusable scopes (e.g., User::scoped(ActiveScope::class)).
    • API layers: Standardize query logic across microservices or monoliths with shared scope classes.
    • Testing: Simplify mocking/scoping in unit/integration tests by instantiating scopes directly.

When to Consider This Package

  • Adopt if:

    • Your team frequently reuses query logic (e.g., "active records," "published items") across models/controllers.
    • You’re using Laravel 11/12 and PHP 8.2+ (avoids legacy dependency overhead).
    • You want to future-proof against Laravel’s potential native local scope support (minimal migration effort).
    • Your scopes need parameters (e.g., AgeScope::class, [25, 30]).
  • Look elsewhere if:

    • You need complex nested scopes (this package focuses on simplicity; consider custom trait-based solutions).
    • Your team prefers global scopes (this is for local, per-query use).
    • You’re on Laravel <11 or PHP <8.2** (check past releases for compatibility).
    • You require advanced query builder features (e.g., subqueries, joins) not covered by basic Scope interface.

How to Pitch It (Stakeholders)

For Executives: "This package lets our devs reuse query logic (e.g., filtering ‘active’ users) like building blocks—cutting duplicate code and speeding up API/model development. It’s a lightweight, Laravel-native solution that aligns with future framework updates, reducing long-term tech debt. Think of it as ‘copy-paste’ for database queries, but cleaner and scalable."

For Engineering: *"Leverage this to:

  • Replace repetitive where() calls in controllers with scoped classes (e.g., Model::scoped(ActiveScope::class)).
  • Support parameterized scopes (e.g., AgeScope::class, [25, 40]).
  • Align with Laravel’s proposed local scopes—minimal effort to adopt now, zero refactor later. Installation: composer require mpyw/laravel-local-class-scope. Works with Laravel 11/12 and PHP 8.2+."*
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.
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium