Download the PHP package kesoji/laravel-removable-global-scopes without Composer
On this page you can find all versions of the php package kesoji/laravel-removable-global-scopes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kesoji/laravel-removable-global-scopes
More information about kesoji/laravel-removable-global-scopes
Files in kesoji/laravel-removable-global-scopes
Package laravel-removable-global-scopes
Short Description Dynamically remove global scopes from Eloquent models in Laravel
License MIT
Informations about the package laravel-removable-global-scopes
Laravel Removable Global Scopes
A Laravel package that adds the ability to dynamically remove global scopes from Eloquent models.
Installation
You can install the package via composer:
Usage
Add the RemovableGlobalScopes
trait to your Eloquent model:
Removing a Single Global Scope
You can remove a global scope by its name, class, or instance:
Removing Multiple Global Scopes
Remove multiple global scopes at once:
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:
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:
Testing
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-removable-global-scopes with dependencies
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0