PHPackages                             akr4m/scoping - 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. akr4m/scoping

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

akr4m/scoping
=============

This scopes allow you to add constraints to all queries for a given model. Filter your data easily.

v1.0.2(4y ago)199MITPHPPHP &gt;=5.4.0

Since Mar 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/akr4m/Filter-Scoping)[ Packagist](https://packagist.org/packages/akr4m/scoping)[ RSS](/packages/akr4m-scoping/feed)WikiDiscussions master Synced today

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Filter Scoping your Queries
===========================

[](#filter-scoping-your-queries)

This scopes allow you to add constraints to all queries for a given model. Filter your data easily.

Installation
============

[](#installation)

Simply add the package to your `composer.json` file and run `composer update`.

```
composer require akr4m/scoping

```

Usage
=====

[](#usage)

Add the trait to your model and your search rules.

```
use akr4m\scoping\Traits\CanBeScoped;

class Post extends Model
{
    use CanBeScoped;
}
```

Add scopes in `abcController.php` like this

```
public function __invoke(Request $request)
{
    $posts  = App\Post::withScopes($this->scopes())->get();
}

protected function scopes()
{
    return [
        // Must declare the `Scope` files
        'topic' => new TopicScope(),
        'month' => new MonthScope(),
        'year' => new YearScope(),
    ];
}
```

`TopicScope.php` file would be like this

```
use akr4m\scoping\Scoping\Contracts\Scope;
use Illuminate\Database\Eloquent\Builder;

class TopicScope implements Scope
{
    public function apply(Builder $builder, $value)
    {
        return $builder
            ->whereHas('topics', function ($builder) use ($topic) {
                $builder->where('slug', $value);
            });
    }
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~477 days

Total

3

Last Release

1658d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1eb3d42757dc0c0cb45aebff7a5d82fc65b07c51327c5264091869b4395eade9?d=identicon)[akr4m](/maintainers/akr4m)

---

Top Contributors

[![akr4m](https://avatars.githubusercontent.com/u/17238742?v=4)](https://github.com/akr4m "akr4m (4 commits)")[![g4bbar](https://avatars.githubusercontent.com/u/41791083?v=4)](https://github.com/g4bbar "g4bbar (1 commits)")

---

Tags

laraveldatabasemodeleloquentfilterscope

### Embed Badge

![Health badge](/badges/akr4m-scoping/health.svg)

```
[![Health](https://phpackages.com/badges/akr4m-scoping/health.svg)](https://phpackages.com/packages/akr4m-scoping)
```

###  Alternatives

[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)[czim/laravel-filter

Filter for Laravel Eloquent queries, with support for modular filter building

8973.0k3](/packages/czim-laravel-filter)

PHPackages © 2026

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