Available Filters

LaraGrid provides several filter classes out of the box:

  1. BaseFilter: This is the abstract base class for all filter types. It defines the basic structure and methods that all filters must have. It has methods like setBuilder which sets a closure that modifies the query builder based on the filter's value.

  2. TextFilter: This class extends BaseFilter and is used for filtering text fields. It sets the filtration type by default to LIKE and filter type to TEXT.

use BoredProgrammers\LaraGrid\Filters\TextFilter;

Column::make('name', 'Name')->setFilter(TextFilter::make()),
  1. SelectFilter: This class extends BaseFilter and is used for filtering select fields. It sets the filtration type by default to EQUAL and filter type to SELECT. It also has methods to set options for the select filter.

use BoredProgrammers\LaraGrid\Filters\SelectFilter;

Column::make('status', 'Status')
    ->setFilter(
        SelectFilter::make()->setOptions([
            'active' => 'Active',
            'inactive' => 'Inactive',
        ])
    ),
  1. DateFilter: This class extends BaseFilter and is used for filtering date fields. It sets the filtration type bu default to DATE_BETWEEN and filter type to DATE.

use BoredProgrammers\LaraGrid\Filters\DateFilter;

Column::make('created_at', 'Created At')->setFilter(DateFilter::make()),
  1. BooleanFilter: This class extends SelectFilter and is used for filtering boolean fields. It sets predefined options for boolean values.

use BoredProgrammers\LaraGrid\Filters\BooleanFilter;

Column::make('is_active', 'Is Active')->setFilter(BooleanFilter::make()),

Filter Types

LaraGrid defines an enum class FilterType that lists the types of filters available: TEXT, SELECT, and DATE.

Filtration Types

LaraGrid defines an enum class FiltrationType that lists the types of filtrations available: LIKE, EQUAL, and DATE_BETWEEN.

Last updated