PHPackages                             kesoji/laravel-removable-global-scopes - 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. kesoji/laravel-removable-global-scopes

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

kesoji/laravel-removable-global-scopes
======================================

Dynamically remove global scopes from Eloquent models in Laravel

v1.0.0(1y ago)00MITPHPPHP ^8.1CI passing

Since May 28Pushed 1y agoCompare

[ Source](https://github.com/kesoji/laravel-removable-global-scopes)[ Packagist](https://packagist.org/packages/kesoji/laravel-removable-global-scopes)[ RSS](/packages/kesoji-laravel-removable-global-scopes/feed)WikiDiscussions main Synced today

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

Laravel Removable Global Scopes
===============================

[](#laravel-removable-global-scopes)

A Laravel package that adds the ability to dynamically remove global scopes from Eloquent models.

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

[](#installation)

You can install the package via composer:

```
composer require kesoji/laravel-removable-global-scopes
```

Usage
-----

[](#usage)

Add the `RemovableGlobalScopes` trait to your Eloquent model:

```
use Illuminate\Database\Eloquent\Model;
use Kesoji\RemovableGlobalScopes\RemovableGlobalScopes;

class User extends Model
{
    use RemovableGlobalScopes;

    // Your model code...
}
```

### Removing a Single Global Scope

[](#removing-a-single-global-scope)

You can remove a global scope by its name, class, or instance:

```
// Remove by name
User::removeGlobalScope('active');

// Remove by class
User::removeGlobalScope(ActiveScope::class);

// Remove by instance
User::removeGlobalScope(new ActiveScope);
```

### Removing Multiple Global Scopes

[](#removing-multiple-global-scopes)

Remove multiple global scopes at once:

```
User::removeGlobalScopes(['active', 'verified', TenantScope::class]);
```

### Important Notes

[](#important-notes)

⚠️ **Warning**: The `removeGlobalScope()` and `removeGlobalScopes()` methods permanently remove global scopes from the model class. This affects all subsequent queries on that model.

If you need to temporarily remove a global scope for a specific query, use Laravel's built-in `withoutGlobalScope()` method instead:

```
// Temporary removal for a single query
User::withoutGlobalScope('active')->get();

// Temporary removal of multiple scopes
User::withoutGlobalScopes(['active', 'verified'])->get();
```

### Return Value

[](#return-value)

The `removeGlobalScope()` method returns the original global scopes array before removal, allowing you to potentially restore them later using Laravel's `addGlobalScope()` method:

```
// Remove and store original scopes
$originalScopes = User::removeGlobalScope('active');

// Do something without the scope...

// Restore if needed
if (isset($originalScopes[User::class]['active'])) {
    User::addGlobalScope('active', $originalScopes[User::class]['active']);
}
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance46

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

403d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a4b91ba81629f2e6df70474624849f70670c27dab39a3b4f7a96654465e0fee3?d=identicon)[kesoji](/maintainers/kesoji)

---

Top Contributors

[![kesoji](https://avatars.githubusercontent.com/u/6465251?v=4)](https://github.com/kesoji "kesoji (10 commits)")

---

Tags

laravelormeloquentglobal-scopes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kesoji-laravel-removable-global-scopes/health.svg)

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

###  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)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.3M18](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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