lacodix/laravel-model-filter
Filter, search, and sort Eloquent models with reusable filter classes and query-string support. Includes built-in types (string, date, number, enum), relation/nested relation filtering, custom complex logic, and filter visualisation.
All filters have a mode for filtering, that can change the behaviour of the filter. The default mode of almost all filters is filtering for "equal" values. The default mode for a string filter is "like".
To change the mode of a filter, just insert the mode propety to the filter:
<?php
namespace App\Models\Filters;
use Lacodix\LaravelModelFilter\Enums\FilterMode;
use Lacodix\LaravelModelFilter\Filters\DateFilter;
class CreatedAfterFilter extends DateFilter
{
public FilterMode $mode = FilterMode::GREATER_OR_EQUAL;
protected string $field = 'created_at';
}
There are several filter modes available, but not all modes make sense with all filter types. You will find the usable modes for each filter type in the filter types section of this documentation
All available modes are:
How can I help you explore Laravel packages today?