You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/filters.md
+16-4Lines changed: 16 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -361,7 +361,7 @@ You can filter offers by joining two values, for example: `/offers?price[gt]=12.
361
361
362
362
The exists filter allows you to select items based on nullable field value.
363
363
364
-
Syntax: `?property[exists]=<true|false|1|0>`
364
+
Syntax: `?exists[property]=<true|false|1|0>`
365
365
366
366
Enable the filter:
367
367
@@ -385,10 +385,22 @@ class Offer
385
385
}
386
386
```
387
387
388
-
Given that the collection endpoint is `/offers`, you can filter offers on nullable field with the following query: `/offers?transportFees[exists]=true`.
388
+
Given that the collection endpoint is `/offers`, you can filter offers on nullable field with the following query: `/offers?exists[transportFees]=true`.
389
389
390
390
It will return all offers where `transportFees` is not `null`.
391
391
392
+
#### Using a Custom NotNull Query Parameter Name
393
+
394
+
A conflict will occur if `exists` is also the name of a property with the search filter enabled.
395
+
Luckily, the query parameter name to use is configurable:
396
+
397
+
```yaml
398
+
# api/config/packages/api_platform.yaml
399
+
api_platform:
400
+
collection:
401
+
notnull_parameter_name: 'notempty' # the URL query parameter to use is now "notempty"
402
+
```
403
+
392
404
### Order Filter (Sorting)
393
405
394
406
The order filter allows to sort a collection against the given properties.
@@ -680,7 +692,7 @@ final class RegexpFilter extends AbstractContextAwareFilter
680
692
) {
681
693
return;
682
694
}
683
-
695
+
684
696
$parameterName = $queryNameGenerator->generateParameterName($property); // Generate a unique parameter name to avoid collisions with other filters
0 commit comments