Digging Deeper
Required Filters
Overview
You can specify that Filter::field()
, Filter::relation()
, Filter::morphRelation()
, Filter::morphType()
and Filter::custom()
filters must be required.
- When a required filter is not used, a
RequiredFilterException
is thrown. RequiredFilterException
extends LaravelsValidationException
.- You can let this bubble up to your controller for the default laravel 422 response.
- This exception CAN NOT be suppressed.
Marking As Required
Relaxing The Required Scope
- Sometimes you may want a filter to be required ONLY if it’s parent has been filtered.
- You can set the
scoped
parameter totrue
to achieve this.
- You can set the