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 Global Scope Laravel Package

sofa/laravel-global-scope

Deprecated: Laravel 5.2+ changed global scopes, so this package is no longer valid. For Laravel 5.0–5.1, it provides an abstract Eloquent GlobalScope to define scopes via apply() and makes removing scopes from queries easier.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Legacy System Modernization: Justifies adoption for Laravel 5/5.1 projects still in maintenance mode (pre-5.2) where global scopes were required but lacked intuitive removal mechanisms.
  • Build vs. Buy: Avoids reinventing the wheel for a niche but critical feature (global scopes) in older Laravel versions, reducing dev time and risk.
  • Use Cases:
    • Soft Deletes: Enforce global soft-delete behavior across models without manual query adjustments.
    • Multi-Tenant Isolation: Apply tenant-specific filters automatically to all queries.
    • Role-Based Access Control (RBAC): Globally restrict queries to user roles without repetitive where clauses.
    • Audit Trails: Filter active/inactive records by default (e.g., is_active = true).
  • Roadmap Alignment: Supports migration strategies for projects upgrading from Laravel 5.x to 5.2+ by providing a temporary solution for global scopes.

When to Consider This Package

  • Laravel Version: Only for Laravel 5/5.1 (invalid in 5.2+ due to native global scope support).
  • Legacy Codebases: Projects stuck on pre-5.2 Laravel where native global scopes are incompatible or require workarounds.
  • Specific Pain Points:
    • Need to dynamically remove global scopes (e.g., for admin bypass or bulk operations).
    • Lack of consistent scope application across models (e.g., avoiding repetitive withoutGlobalScopes() calls).
  • Look Elsewhere If:
    • Using Laravel 5.2+: Native global scopes are sufficient (no package needed).
    • Requiring advanced scope logic: Consider custom base classes or Laravel’s built-in Scope interface.
    • Need active maintenance: Package is archived (last commit 2015); evaluate risk for long-term projects.
    • Performance-critical: Minimal overhead, but native scopes may be optimized better in newer Laravel versions.

How to Pitch It (Stakeholders)

For Executives: "This package solves a technical debt issue for our Laravel 5/5.1 projects by standardizing global query filters—like soft deletes or tenant isolation—without manual intervention. It’s a low-risk, MIT-licensed solution that reduces dev time and query inconsistencies, aligning with our modernization roadmap. Since Laravel 5.2+ handles this natively, it’s a short-term fix for legacy systems, saving costs vs. rewriting scopes from scratch."

For Engineering: *"For Laravel 5/5.1, this package provides a clean abstraction for global scopes with two key advantages:

  1. Consistency: Enforce rules (e.g., is_active = true) across all queries without repetitive withoutGlobalScopes().
  2. Flexibility: Easily remove scopes when needed (e.g., for admin tools) via a single method. It’s a lightweight (~50 LOC) MIT package that works with PHP 5.4+. Not for new projects—only for maintaining legacy systems. For greenfield work, use Laravel’s native global scopes (5.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.
amashukov/lnd-client-php
althinect/enum-permission
andydefer/laravel-actions
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor