PHPackages                             duc\_cnzj/model-filter - 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. [Search &amp; Filtering](/categories/search)
4. /
5. duc\_cnzj/model-filter

ActiveLibrary[Search &amp; Filtering](/categories/search)

duc\_cnzj/model-filter
======================

Package description here.

v1.0(6y ago)05[1 PRs](https://github.com/DuC-cnZj/model-filter/pulls)MITPHPCI failing

Since Jun 16Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/DuC-cnZj/model-filter)[ Packagist](https://packagist.org/packages/duc_cnzj/model-filter)[ RSS](/packages/duc-cnzj-model-filter/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

 model filter
==============

[](#-model-filter-)

[![Build Status](https://github.com/DuC-cnZj/model-filter/workflows/Tests/badge.svg)](https://github.com/DuC-cnZj/model-filter/actions)[![codecov](https://camo.githubusercontent.com/57b051e81c106b5db06428d4507a3f4d6bcafd299219a0d8baeb1cf0584dbcc5/68747470733a2f2f636f6465636f762e696f2f67682f4475432d636e5a6a2f6d6f64656c2d66696c7465722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/DuC-cnZj/model-filter)

Installing
----------

[](#installing)

```
$ composer require duc_cnzj/model-filter
```

Usage
-----

[](#usage)

1. 生成filter

> 自动会加上 Filter 后缀

```
php artisan make:filter User
or
php artisan make:filter UserFilter
```

Model 引入 Filter

```
# User.php

class User extends Model
{
    use HasFilter;
}
```

控制器中使用

```
User::filter($request)->get();
or
User::filter(new UserFilter($request))->get();
or
User::filter(['name' => 'duc'])->get();
```

筛选filter参数

```
User::filter($request, ['name'])->get();
```

带上前缀

```
User::filter($request, ['name'], 'user')->get();
```

自定义入参过滤规则

```
# 默认是
return array_filter($inputs, function ($item) {
    return !is_null($item);
});

# 自定义的话，请在 boot 方法这样写
Filter::setGetFilterCallback('array_filter'); //callback 第一个参数就是inputs
Filter::setGetFilterCallback(function ($items) {
    return array_filter($items, function ($value, $key) {
        return $key !== 'sb';
    }, ARRAY_FILTER_USE_BOTH);
}); //callback 第一个参数就是inputs
```

Contributing
------------

[](#contributing)

License
-------

[](#license)

MIT

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance56

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

2252d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23514869?v=4)[duc](/maintainers/DuC-cnZj)[@duc-cnzj](https://github.com/duc-cnzj)

---

Top Contributors

[![duc-cnzj](https://avatars.githubusercontent.com/u/23514869?v=4)](https://github.com/duc-cnzj "duc-cnzj (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/duc-cnzj-model-filter/health.svg)

```
[![Health](https://phpackages.com/badges/duc-cnzj-model-filter/health.svg)](https://phpackages.com/packages/duc-cnzj-model-filter)
```

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

137236.2k8](/packages/statamic-rad-pack-runway)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3622.8k](/packages/duncanmcclean-statamic-cargo)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21327.3k4](/packages/ecotone-laravel)

PHPackages © 2026

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