| Package Data | |
|---|---|
| Maintainer Username: | willrowe |
| Maintainer Contact: | wrowe@will-rowe.com (Will Rowe) |
| Package Create Date: | 2014-11-20 |
| Package Last Update: | 2017-05-19 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-02 15:07:11 |
| Package Statistics | |
|---|---|
| Total Downloads: | 38 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 2 |
| Total Watchers: | 1 |
| Total Forks: | 1 |
| Total Open Issues: | 0 |
This package includes some useful global scopes for Laravel Eloquent.
Installation
Traits
Usage
Release Notes
Version Compatibility
License
composer require wowe/laravel-eloquent-scopes
When this trait is added to an Eloquent model, it will only return rows which have the active field set to true.
If you want to use a field with a different name than active, set a constant called ACTIVE on the Eloquent model to whichever name you would like to use.
The following methods are included with the trait:
deactivate: sets the active field to false.activate: sets the active field to true.withInactive: will include all entries in results regardless of the value of the active field.onlyInactive: will include only those entries with active fields set to false.Add the ActivatableTrait to an Eloquent model.
use Wowe\Eloquent\Scopes\ActivatableTrait;
class Test extends \Eloquent
{
use ActivatableTrait;
const ACTIVE = 'is_active';
}
// Get all entries that are active
Test::all();
// Get a single entry only if active
Test::find(1);
// Get all entries
Test::withInactive()->get();
// Get all inactive entries
Test::inactiveOnly()->get();
This Package | Laravel -------------|-------- 1.x.x | 4.2.x 2.x.x | 5.0.x 3.x.x | 5.1.x
This package is open-sourced software licensed under the MIT license