ensi/laravel-query-builder-helpers 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

ensi/laravel-query-builder-helpers

Composer 安装命令:

composer require ensi/laravel-query-builder-helpers

包简介

This package contains extensions for laravel-query-builder

README 文档

README

Latest Version on Packagist Tests Total Downloads

The laravel-query-builder-helper package is a set of classes that simplify the creation of available filters for the laravel-query-builder package from Spatie.

Installation

You can install the package via composer:

composer require ensi/laravel-query-builder-helpers

Version Compatibility

Laravel query builder helpers Laravel PHP
^0.1.0 ^9.x ^8.1
^0.1.4 ^9.x || ^10.x ^8.1
^0.1.7 ^9.x || ^10.x || ^11.x ^8.1
^0.1.14 ^9.x || ^10.x || ^11.x || ^12.x ^8.1
^0.1.15 ^9.x || ^10.x || ^11.x || ^12.x || ^13.x ^8.1

Basic Usage

Creating a filter

Filters are created by applying the static make method and then calling the chain of filter methods.

use Ensi\QueryBuilderHelpers\Filters\StringFilter;

StringFilter::make('name')->contain()->endWith()->empty();

The following filter classes are currently available:

  • StringFilter
  • NumericFilter
  • DateFilter
  • PlugFilter (a stub for passing additional parameters to another filter)
  • ExtraFilter (described in the section "Additional filters")

Each filter type has its own suffix, which is added to the name passed to the make method. For example, by default, the filter empty has the suffix _empty, and the filter gt is _gt:

NumericFilter::make('rank')->exact()->empty()->gt()->lt();

As a result, we will get four filtering options available for search queries.

  • rank
  • rank_empty
  • rank_gt
  • rank_lt

Passing filters to the allowed Filters method

To transfer the received filters to the allowedFilters method of the Spatie package, the array will need to be destructured.

$this->allowedFilters([
    ...NumericFilter::make('rank')->exact()->empty()->gt()->lt(),
]);

Additional filters

The ExtraFilter class is used by the aforementioned classes, but can also be used separately.

Useful methods include:

  • nested (registers a set of nested filters)
  • predefined (creates a predefined filter that includes complex filtering)
  • and others
...ExtraFilter::nested('page', [
    ...InputFilter::make('title', 'page_title')->empty()->exact()->contain(),
]),

Configuration

In the file **config.php ** you can customize the applied suffixes. You can also set up the like operator used in search queries there.

'suffixes' => [
    'equal' => '',
    'greater' => '_gt',
    'less' => '_lt',
    ...
],

'like_operator' => 'LIKE',

Contributing

Please see CONTRIBUTING for details.

Testing

  1. composer install
  2. composer test

By default, testing takes place using in-memory DataBase SQLite. SQLite does not support some functions, for example: json_contains. To test these functions, copy phpunit.xml.dist to phpunit.xml and specify the configuration with connection to another database in the php section. When writing such tests, use the skip function to skip tests using the default connection.

->skip(fn () => DB::getDriverName() === 'sqlite', 'db driver does not support this test');

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

The MIT License (MIT). Please see License File for more information.

ensi/laravel-query-builder-helpers 适用场景与选型建议

ensi/laravel-query-builder-helpers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47.59k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 05 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 ensi/laravel-query-builder-helpers 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-02