Digging Deeper
Modifiers
Overview
Modifiers are ways to slightly alter the way that a filter works.
How To Use
Append :{modifierName}
to the type
of the filter.
- i.e.
$like:start
.
Multiple modifiers can be applied.
- i.e.
$like:start:end
.
Core Filter Modifiers
Some of the core filters provided by this package have modifiers.
:start
- matches only the start of fieldLIKE 'Laravel%'
.:end
- matches only the end of fieldLIKE '%Laravel'
.
:start
- matches only the start of fieldNOT LIKE 'Laravel%'
.:end
- matches only the end of fieldNOT LIKE '%Laravel'
.
:null
- also does aor "{$target}" is null
.
:null
- also does aand "{$target}" is not null
.
Configuring Modifiers
By default, all filter modifiers are enabled.
Allowing
Though, you can specify only specific modifiers to enable.
public function allowedFilters(): AllowedFilterList
{
return Filter::only(
Filter::field('name', [FilterType::LIKE->withModifiers('end')])
);
}
Disabling
You can also disable all modifiers.
public function allowedFilters(): AllowedFilterList
{
return Filter::only(
Filter::field('name', [FilterType::LIKE->withoutModifiers()])
);
}