定制 alkhachatryan/laravel-enhanced-filters 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alkhachatryan/laravel-enhanced-filters

Composer 安装命令:

composer require alkhachatryan/laravel-enhanced-filters

包简介

Extensible Laravel filtering engine with Amazon-style faceted search. Supports field types (string, numeric, boolean, date), operator-level validation, clean structured errors, and automatic query builder mapping. Perfect for APIs, dashboards, and complex multi-field filters.

README 文档

README

Latest Version on Packagist Total Downloads

image

Want to have a filters like this? Go ahead😎



Enhanced Filters for Laravel provide a flexible, AWS-like filtering system for filtering. You can define fields, operators, and their validation rules, then use them to filter queries efficiently. ✅

It supports multiple field types, each with their own operators. The package handles validation, ensures only supported operators are used, and integrates seamlessly with Laravel request classes. 💡

Perfect for building advanced search and filter systems without writing repetitive query logic. 🚀

This is an API(backend, no UI) implementation only

Usage

Define Enhanced Filters in your Request Class

Your request class should implement HasEnhancedFilters and use EnhancedFilters trait:

<?php
use Alkhachatryan\LaravelEnhancedFilters\HasEnhancedFilters;
use Alkhachatryan\LaravelEnhancedFilters\Traits\EnhancedFilters;
use Alkhachatryan\LaravelEnhancedFilters\FieldTypes\{
    BooleanFieldType,
    DateFieldType,
    NumericFieldType,
    StringFieldType
};

class ListBlogPostsRequest extends FormRequest implements HasEnhancedFilters
{
    use EnhancedFilters;

    public function rules(): array
    {
        return [
            // your basic rules
            'enhancedFilters' => [new EnhancedFilterRule($this->enhancedFilters())],
        ];
    }

    public function enhancedFilters(): array
    {
        return [
            'title' => new StringFieldType(['nullable', 'max:255']),
            'body' => new StringFieldType(['nullable', 'max:5000']),
            'author_id' => new NumericFieldType(['nullable', 'int'),
            'rating' => new NumericFieldType(['nullable', 'float']),
            'is_active' => new BooleanFieldType(['nullable']),
            'created_at' => new DateFieldType(['nullable']),
        ];
    }
}

Call the filter class in your controller/service/business logic class

        use Alkhachatryan\LaravelEnhancedFilters\QueryBuilderEnhancedFilter;

        // Later in the method
        $queryBuilderEnhancedFilter = app(QueryBuilderEnhancedFilter::class);
        $enhancedFilters = $request->enhancedFiltersWithValues();
        $query = BlogPost::query();

        // Your specific querying
        
        $queryBuilderEnhancedFilter->filter($query, $enhancedFilters);

        // Your ordering staff

        return $query->get(); // or whatever

Send your enhanced request

The example in postman below image

Installation

composer require alkhachatryan/laravel-enhanced-filters

That's it.

More about the package

So the package provides the extension for your request classes for filtering.

You will be able to filter like: FIELD - FILTERING_OPERATOR - VALUE

The package provides the following field-types:

  1. BooleanFieldType
  2. DateFieldType
  3. NumericFieldType
  4. StringFieldType

Each of them have their own specific filtering operators, but also have the common ones.

(not that true and false values(i.e. boolean) should be sent as a __true__ or __false__ strings

Common filtering operators for all field types

  • equals - string/numberic value
  • notEquals - string/numberic value
  • isNull - __true__ or __false__
  • isNotNull - __true__ or __false__

Boolean filtering operators

  • isTrue - __true__ or __false__
  • isFalse - __true__ or __false__

Date filtering operators

  • before - a date formatted Y-m-d\TH:i:sP
  • beforeOrEquals - a date formatted Y-m-d\TH:i:sP
  • after - a date formatted Y-m-d\TH:i:sP
  • afterOrEquals - a date formatted Y-m-d\TH:i:sP
  • yearEquals - a date formatted Y
  • notYearEquals - a date formatted Y
  • monthEquals - a date formatted m
  • notMonthEquals - a date formatted m
  • dayEquals - an integer [1-31]
  • notDayEquals - an integer [1-31]
  • hourEquals - an integer [0-23]
  • notHourEquals - an integer [0-23]
  • minuteEquals - an integer [0-59]
  • notMinuteEquals - an integer [0-59]
  • secondEquals - an integer [0-59]
  • notSecondEquals - an integer [0-59]

Numeric filtering operators

  • greaterThan - numeric value
  • greaterThanOrEquals - numeric value
  • lessThan - numeric value
  • lessThanOrEquals - numeric value

String filtering operators

  • contains - string value
  • notContains - string value
  • startsWith - string value
  • notStartsWith - string value
  • endsWith - string value
  • notEndsWith - string value
  • lengthEquals - integer value
  • lengthNotEquals - integer value
  • lengthGreaterThan - integer value
  • lengthLessThan - integer value

Versioning

The package has a semantic versioning X.Y.Z where X - a version of supported Laravel, Y a number of feature commits and a Z a number of bugfixes

alkhachatryan/laravel-enhanced-filters 适用场景与选型建议

alkhachatryan/laravel-enhanced-filters 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 12 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「query」 「laravel」 「filters」 「Enhanced」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 alkhachatryan/laravel-enhanced-filters 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 alkhachatryan/laravel-enhanced-filters 我们能提供哪些服务?
定制开发 / 二次开发

基于 alkhachatryan/laravel-enhanced-filters 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-12-02