Skip to content

Commit 31596ec

Browse files
Update docs for beginsWithStrict
1 parent 82e16d5 commit 31596ec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/features/filtering.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 1
55

66
The `filter` query parameters can be used to add `where` clauses to your Eloquent query. Out of the box we support filtering results by partial attribute value, exact attribute value or even if an attribute value exists in a given array of values. For anything more advanced, custom filters can be used.
77

8-
By default, all filters have to be explicitly allowed using `allowedFilters()`. This method takes an array of strings or `AllowedFilter` instances. An allowed filter can be partial, exact, scope or custom. By default, any string values passed to `allowedFilters()` will automatically be converted to `AllowedFilter::partial()` filters.
8+
By default, all filters have to be explicitly allowed using `allowedFilters()`. This method takes an array of strings or `AllowedFilter` instances. An allowed filter can be partial, beginsWithStrict, exact, scope or custom. By default, any string values passed to `allowedFilters()` will automatically be converted to `AllowedFilter::partial()` filters.
99

1010
## Basic usage
1111

@@ -31,21 +31,27 @@ $users = QueryBuilder::for(User::class)
3131
// $users will contain all users that contain "seb" OR "freek" in their name
3232
```
3333

34+
By passing column name strings to `allowedFilters`, **partial** filters are automatically applied.
35+
3436
## Disallowed filters
3537

3638
Finally, when trying to filter on properties that have not been allowed using `allowedFilters()` an `InvalidFilterQuery` exception will be thrown along with a list of allowed filters.
3739

3840

3941
## Disable InvalidFilterQuery exception
4042

41-
You can set in configuration file to not throw an InvalidFilterQuery exception when a filter is not set in allowedFilter method.
43+
You can set in configuration file to not throw an InvalidFilterQuery exception when a filter is not set in allowedFilter method. This does **not** allow using any filter, it just disables the exception.
4244

4345
```php
4446
'disable_invalid_filter_query_exception' => true
4547
```
4648

4749
By default the option is set false.
4850

51+
## Partial and beginsWithStrict filters
52+
53+
By default, all values passed to `allowedFilters` are converted to partial filters. The underlying query will be modified to use a `LIKE LOWER(%value%)` statement. Because this can cause missed indexes, it's often worth considering a `beginsWithStrict` filter instead. This filter will use a `LIKE value%` statement instead.
54+
4955
## Exact filters
5056

5157
When filtering IDs, boolean values or a literal string, you'll want to use exact filters. This way `/users?filter[id]=1` won't match all users having the digit `1` in their ID.

0 commit comments

Comments
 (0)