Filterable
Home
📦 Installation
  • Setting Up Filterable
  • Discover Command
  • Listing All Filters
  • Testing Filters
  • Inspecting Filterable Classes
GitHub
Home
📦 Installation
  • Setting Up Filterable
  • Discover Command
  • Listing All Filters
  • Testing Filters
  • Inspecting Filterable Classes
GitHub
  • Home
  • Introduction
  • Installation
  • Service Provider
  • How It Works
  • Engines

    • Invokable
    • Tree
    • Ruleset
    • Expression
  • Features

    • Header-Driven Filter Mode
    • Auto Register Filterable Macro
    • Conditional Logic
    • Filter Aliases
    • Through callbacks
    • Auto Binding
    • Custom engines
    • Data Provisioning
  • Execution

    • Invoker
  • API

    • Filterable
    • Filterable facade
    • Payload
    • Sorter
  • CLI

    • Setup Filterable
    • Discover Filters
    • Test Filter
    • List Filters
    • Inspect Filter
  • Event System
  • Profile Management
  • Profiler
  • Sorting
  • Authorization
  • Validation
  • Sanitization

Testing Filters

Purpose

The filterable:test command allows you to test and debug filter classes directly from the command line. It applies the specified filter on a given model and displays the resulting SQL query, helping you verify that your filters behave as expected.


Usage

php artisan filterable:test {filter} --model=User --data="status=active,age=30"

Arguments

NameDescriptionRequired
filterThe name of the filter class (e.g., UserFilter). It must exist in your configured filter namespace.✅ Yes

Options

OptionDescriptionExample
--modelThe Eloquent model class to apply the filter on. Defaults to App\Models\{ModelName} if not fully qualified.--model=User
--dataA comma-separated list of filter key-value pairs to simulate a filter input.--data="status=active,age=30"

Example

php artisan filterable:test UserFilter --model=User --data="status=active,age=30"

Output:

🔍 Testing filter: App\Http\Filters\UserFilter
🧩 Model: App\Models\User

Applied filters:
  • status = active
  • age = 30

✅ Query:
select * from "users" where "status" = 'active' and "age" = 30;

How It Works

  1. The command resolves your filter class from the configured namespace (filterable.filter_namespace).
  2. It instantiates the model and builds an Eloquent query.
  3. The filter is applied to that query using its apply() method.
  4. The resulting SQL query is displayed in the console.
Edit this page
Last Updated:
Contributors: kettasoft
Prev
Discover Filters
Next
List Filters