Filterable
Home
📦 Installation
GitHub
Home
📦 Installation
GitHub
  • Home
  • Introduction
  • Installation
  • How It Works
  • Engines

    • Invokable
    • Tree
    • Ruleset
    • Expression
  • Features

    • Header-Driven Filter Mode
  • Authorization
  • Validation
  • Sanitization

Tree Engine

This engine allows for advanced query filtering using a logical tree structure with AND/OR grouping. It is ideal for complex, nested conditions that simulate SQL-like logical grouping.

Overview

The engine processes a nested JSON structure where each node is either:

  • A logical group (and or or)
  • A filter condition

This structure is then translated into an Eloquent query builder statement in Laravel.

Example JSON Filter Request

{
  "filter": {
    "and": [
      { "field": "status", "operator": "eq", "value": "active" },
      {
        "or": [
          { "field": "age", "operator": "gt", "value": 25 },
          { "field": "city", "operator": "eq", "value": "Cairo" }
        ]
      }
    ]
  }
  //...
}

Config Options

KeyTypeDescription
logic_operatorstringDefault logic when none is provided (and or or)
allowed_operatorsarrayList of allowed operator aliases and their SQL equivalents
depth_limitint/nullMaximum nesting level allowed for groups. Null for unlimited
normalize_keysboolWhether to convert field names to lowercase automatically

Supported Operators

AliasSQL Equivalent
eq=
neq!=
gt>
lt<
gte>=
lte<=
likelike
nlikenot like
inin
ninnot in
nullis null
notnullis not null
betweenbetween

Error Handling

  • An exception is thrown if:
  • The tree exceeds the depth_limit
  • An invalid or disallowed operator is used
Edit this page
Last Updated:
Contributors: Abdalrhman Emad Saad
Prev
Invokable
Next
Ruleset