PHPackages                             feixun/base-search - 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. feixun/base-search

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

feixun/base-search
==================

Webman plugin feixun/base-search

v0.0.3(3y ago)219MITPHP

Since Sep 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/zkamisama/BaseSearch)[ Packagist](https://packagist.org/packages/feixun/base-search)[ RSS](/packages/feixun-base-search/feed)WikiDiscussions main Synced today

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

📖 目录
----

[](#book-目录)

- [安装](#%E5%AE%89%E8%A3%85)
- [使用](#%E4%BD%BF%E7%94%A8)

安装
--

[](#安装)

`composer require feixun/base-search illuminate/database`

使用
--

[](#使用)

\#####模型

```
//app\model\User.php
class User extends Model
{
    //在模型里面使用 HasSearch trait
    use HasSearch;

    //关系名称翻译
    public $relationTrans = [
        'comments' => '评论',
        'posts' => '帖子'
    ];
    //字段属性翻译 不设置的时候默认取数据表备注
    public $attributeLabels = [
        'created_at' => '创建时间',
        'updated_at' => '更新时间'
    ];

    /**
     * 模型关联phpdoc必须有@return注释  会自动根据返回类型查找符合的关联关系
     * 评论
     * @return HasMany
     */
    public function comments(): HasMany
    {
        return $this->hasMany(Comment::class, 'user_id');
    }

    /**
     * @return HasMany
     */
    public function posts(): HasMany
    {
        return $this->hasMany(Post::class, 'user_id');
    }
}
```

\#####控制器

```
//app\controller\indexController.php
class Index
{
    public function index(Request $request)
    {
        $result = User::search([
            'page'     => 1, //页码
            'pageSize' => 10, //每页条数
            'filters'  => [
               [
                   "field_name"   => "name",
                   "field_values" => [
                       "admin"
                   ],
                   "operator"     => "LIKE",
                   "filterGroup"  => "1"
               ],
               [
                   "field_name"   => "comments",
                   "type" => "relation",
                   "filters"   => [
                        [
                            "field_name" => "content",
                            "field_values" => [
                                "这是一条评论"
                            ],
                            "operator" => "EQ"
                        ]
                   ],
                   "filterGroup"  => "1"
               ],
               [
                   "field_name"   => "gender",
                   "field_values" => [
                       "2"
                   ],
                   "operator"     => "EQ",
                   "filterGroup"  => "2"
               ],
               [
                   "field_name"   => "created_at",
                   "field_values" => [
                       "2022-09-01"
                   ],
                   "operator"     => "GTE"
               ]
            ],
            'orders' => [ //排序
                [
                    'field' => 'id',
                    'isAsc' => false
                ]
            ],
            'relations' => ['comments', 'posts']
        ]);
        return json($result);
    }
}
```

上面的查询会生成以下 SQL:

```
select * from `users` where `created_at` >= "2022-09-01" and ((`name` like "admin" and exists (select * from `comments` where `users`.`id` = `comments`.`user_id` and `content` = "这是一条评论")) or (`gend
er` = 2)) order by `id` desc limit 10 offset 0
```

```
select * from `comments` where `comments`.`user_id` in (2, 4)
```

```
select * from `posts` where `posts`.`user_id` in (2, 4)
```

\#####操作符

```
[
    'LIKE' => '包含', //like
    'NLIKE' => '不包含', //not like
    'IS' => '为空', // is null
    'ISN' => '不为空', //is not null
    'IN' => '属于', // in
    'NIN' => '不属于', // not in
    'EQ' => '等于', // =
    'LT' => '小于', // >
    'GT' => '大于', // >
    'LTE' => '小于等于', //  '大于等于', // >=
    'N' => '不等于',  //
    'BETWEEN' => '介于', // between
];
```

\#####获取字段配置信息

```
    $fields = User::searchFields();

    // 返回结果
    // [
    //     {
    //         "type": "field",
    //         "field": "id",
    //         "label": "id",
    //         "operator": [
    //             "LIKE",
    //             "NLIKE",
    //             "IN",
    //             "NIN",
    //             "EQ",
    //             "N",
    //             "IS",
    //             "ISN"
    //         ]
    //     },
    //     {
    //         "type": "field",
    //         "field": "name",
    //         "label": "用户名",
    //         "operator": [
    //             "IN",
    //             "NIN",
    //             "EQ",
    //             "GT",
    //             "GTE",
    //             "LT",
    //             "LTE",
    //             "N",
    //             "BETWEEN"
    //         ]
    //     },
    //     {
    //         "type": "relation",
    //         "field": "comments",
    //         "label": "评论",
    //         "relation_fields": [
    //             {
    //                 "type": "field",
    //                 "field": "id",
    //                 "label": "id",
    //                 "operator": [
    //                     "LIKE",
    //                     "NLIKE",
    //                     "IN",
    //                     "NIN",
    //                     "EQ",
    //                     "N",
    //                     "IS",
    //                     "ISN"
    //                 ]
    //             },
    //             {
    //                 "type": "field",
    //                 "field": "content",
    //                 "label": "内容",
    //                 "operator": [
    //                     "IN",
    //                     "NIN",
    //                     "EQ",
    //                     "GT",
    //                     "GTE",
    //                     "LT",
    //                     "LTE",
    //                     "N",
    //                     "BETWEEN"
    //                 ]
    //             }
    //         ]
    //     },
    // ]
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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 ~2 days

Total

3

Last Release

1387d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/50e5d084215e8b21a148b53052af0c5884e9d47cc5456a1e476348628a7696d5?d=identicon)[zkamisama](/maintainers/zkamisama)

### Embed Badge

![Health badge](/badges/feixun-base-search/health.svg)

```
[![Health](https://phpackages.com/badges/feixun-base-search/health.svg)](https://phpackages.com/packages/feixun-base-search)
```

###  Alternatives

[awesome-nova/dependent-filter

Dependent filters for Laravel Nova

26193.1k](/packages/awesome-nova-dependent-filter)[algolia/php-dom-parser

A simple tool to turn DOM into Algolia search friendly record objects.

181.8k](/packages/algolia-php-dom-parser)

PHPackages © 2026

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