Skip to content

Commit 7e296b4

Browse files
authored
Merge pull request #441 from BatsaxIV/filters-example
Filters - consistency on usage example + date example
2 parents 5262c5b + 690117a commit 7e296b4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

core/filters.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,18 @@ use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
213213
214214
/**
215215
* @ApiResource
216-
* @ApiFilter(DateFilter::class, properties={"dateProperty"})
216+
* @ApiFilter(DateFilter::class, properties={"createdAt"})
217217
*/
218218
class Offer
219219
{
220220
// ...
221221
}
222222
```
223223

224+
Given that the collection endpoint is `/offers`, you can filter offers by date with the following query: `/offers?createdAt[after]=2018-03-19`.
225+
226+
It will return all offers where `createdAt` is superior or equal to `2018-03-19`.
227+
224228
#### Managing `null` Values
225229

226230
The date filter is able to deal with date properties having `null` values.
@@ -259,7 +263,7 @@ class Offer
259263

260264
The boolean filter allows you to search on boolean fields and values.
261265

262-
Syntax: `?property=[true|false|1|0]`
266+
Syntax: `?property=<true|false|1|0>`
263267

264268
Enable the filter:
265269

@@ -291,7 +295,7 @@ It will return all offers where `isAvailableGenericallyInMyCountry` equals `true
291295

292296
The numeric filter allows you to search on numeric fields and values.
293297

294-
Syntax: `?property=int|bigint|decimal...`
298+
Syntax: `?property=<int|bigint|decimal...>`
295299

296300
Enable the filter:
297301

@@ -323,7 +327,7 @@ It will return all offers with `sold` equals `1`.
323327

324328
The range filter allows you to filter by a value Lower than, Greater than, Lower than or equal, Greater than or equal and between two values.
325329

326-
Syntax: `?property[lt]|[gt]|[lte]|[gte]|[between]=value`
330+
Syntax: `?property[<lt|gt|lte|gte|between>]=value`
327331

328332
Enable the filter:
329333

0 commit comments

Comments
 (0)