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

Filter Aliases

Overview

Filter Aliases allow you to assign short or contextual names to filter classes, enabling reusable logic with cleaner naming in requests or controller logic.

โš™๏ธ Setup

In your config/filterable.php, define aliases like so:

'aliases' => Filterable::aliases([
    'active_users' => App\Filters\ActiveUserFilter::class,
    'vip' => App\Filters\VipUserFilter::class,
]),

๐Ÿงช Usage

User::filter('active_users')->get();

The appropriate filter classes will be resolved and applied automatically.

๐Ÿ’ก Benefits

  • Cleaner API interface.
  • Reusability of filter classes across contexts.
  • Improves frontend-backend consistency.

โš ๏ธ Notes

  • Alias names must be unique.
  • If an alias and real filter share the same key, the real filter will be prioritized.
Edit this page
Last Updated:
Contributors: Abdalrhman Emad Saad
Prev
Conditional Logic
Next
Through callbacks