Filterable
Home
๐Ÿ“ฆ Installation
GitHub
Home
๐Ÿ“ฆ Installation
GitHub
  • Home
  • Introduction
  • Installation
  • 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
  • Execution

    • Invoker
  • API

    • Payload
    • Sorter
  • 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