Skip to main content

Overview

This package provides the ability for you to create two different types of custom filters.
You must register your filter classes in the config file eloquent-filtering.php

Field Filter

Class

Usage

Custom Filter

Generally for use when there is no user specified target.

Class

Usage

Custom Filter Notes

Format/Validation

To specify validation messages and attributes along with the rules, you may return a IndexZer0\EloquentFiltering\Filter\Validation\ValidatorProvider from the ::format() method.

Modifiers

Adding modifiers to your custom filters is achieved by:
  • Implement interface:
    • IndexZer0\EloquentFiltering\Filter\Contracts\FilterMethod\Modifiable
  • Use trait:
    • IndexZer0\EloquentFiltering\Filter\Traits\FilterMethod\Composables\HasModifiers
  • Define supportedModifiers() method on the filter class.
  • Using $this->hasModifier('modifier_name') in the apply() implementation.

Qualifying Columns

All FilterMethod classes have access to an EloquentContext object that allows you to qualifyColumn of the target.
  • Use this method to ensure your query is prefixing the column name with the database table.
Benefits of using this method:
  • Prevents ambiguous columns in queries where you’re also joining to another table with the same column.
  • Handles using the correct table name for ->pivot() allowed field filters.