PHPackages                             sofa/laravel-global-scope - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. sofa/laravel-global-scope

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

sofa/laravel-global-scope
=========================

Easy way to define Laravel eloquent global scope.

v0.2(10y ago)3135.2k↑258.8%3MITPHPPHP &gt;=5.4

Since Jul 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jarektkaczyk/laravel-global-scope)[ Packagist](https://packagist.org/packages/sofa/laravel-global-scope)[ RSS](/packages/sofa-laravel-global-scope/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (3)Used By (0)

*NOTICE* Since Laravel 5.2 the way global scopes work changes drastically, so it's no longer required and in fact invalid to use this package.

---

Sofa/Laravel-Global-Scope
=========================

[](#sofalaravel-global-scope)

Easy way to define Eloquent [Global Scopes](http://softonsofa.com/laravel-5-eloquent-global-scope-how-to) in Laravel 5+.

Introduction
------------

[](#introduction)

Global scope in [Eloquent](http://laravel.com/docs/eloquent) is a neat feature. However, it doesn't fit the general idea in Laravel of things being easy to implement, in that it might be very hard to `remove` the scope from a query, unless you know ins and outs of the `Query\Builder`.

That being said, you'll find here short but powerful abstract `GlobalScope` that your scopes will extend, and you only need to implement single method:

1. `apply` - apply any constraints on the `Eloquent\Builder` that your scope requires.
2. OPTIONALLY implement helper methods defining `Eloquent\Builder` macros etc.

Installation
------------

[](#installation)

Package requires **PHP 5.4+** and works with **Laravel 5/5.1**.

1. Require the package in your `composer.json`: ```
        "require": {
            ...
            "sofa/laravel-global-scope": "0.1@dev",
        },

    ```

Usage example
-------------

[](#usage-example)

Let's compare this [basic scope](https://github.com/jarektkaczyk/laravel5-global-scope-example/blob/laravel5-global-scope-example/Sofa/Eloquent/Scopes/PublishedScope.php) with the [enhanced scope](https://github.com/jarektkaczyk/laravel-global-scope/blob/master/examples/PublishedScope.php).

Roadmap
-------

[](#roadmap)

- Abstract GlobalScope - `remove` is done for you
- Easier constraint verification
- Handle twisted edge-cases - multi-level nested subquery wheres
- Generators

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4008d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/34d383bf50d6c73fc747d89a5efacd41ccecc9695aec04148a7c04fc00ef26e7?d=identicon)[jarektkaczyk](/maintainers/jarektkaczyk)

---

Top Contributors

[![jarektkaczyk](https://avatars.githubusercontent.com/u/6928818?v=4)](https://github.com/jarektkaczyk "jarektkaczyk (6 commits)")[![Feijs](https://avatars.githubusercontent.com/u/12059414?v=4)](https://github.com/Feijs "Feijs (1 commits)")[![k1ng440](https://avatars.githubusercontent.com/u/3443226?v=4)](https://github.com/k1ng440 "k1ng440 (1 commits)")

---

Tags

laraveldatabaseeloquentglobal scope

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sofa-laravel-global-scope/health.svg)

```
[![Health](https://phpackages.com/badges/sofa-laravel-global-scope/health.svg)](https://phpackages.com/packages/sofa-laravel-global-scope)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

592456.3k2](/packages/spiritix-lada-cache)[guidocella/eloquent-populator

Guess attributes for Eloquent model factories

7762.7k2](/packages/guidocella-eloquent-populator)[mvanduijker/laravel-model-exists-rule

Validation rule to check if a model exists

22215.3k2](/packages/mvanduijker-laravel-model-exists-rule)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3262.5k4](/packages/toponepercent-baum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
