Skip to content

Commit

Permalink
docs: boolean filter (#2125)
Browse files Browse the repository at this point in the history
  • Loading branch information
adryyy10 authored Jan 13, 2025
1 parent 3962b58 commit 5ac9eaa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions laravel/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,33 @@ This allows to query multiple `isbn` values with a `q` query parameter: `/books?
TODO -->

### BooleanFilter

The `BooleanFilter` allows to filter using an `WHERE` clause on a boolean field with (`true`, `false`, `0`, `1`):

```php
// app/Models/Book.php

use ApiPlatform\Laravel\Eloquent\Filter\BooleanFilter;

#[ApiResource]
#[QueryParameter(key: 'published', filter: BooleanFilter::class)]
class Book extends Model
{
use HasUlids;

public function author(): BelongsTo
{
return $this->belongsTo(Author::class);
}
}
```
Examples:
- `/books?published=true`
- `/books?published=1`
- `/books?published=false`
- `/books?published=0`

### PropertyFilter

Note: We strongly recommend using [Vulcain](https://vulcain.rocks) instead of this filter. Vulcain is faster, allows a better hit rate, and is supported out of the box in the API Platform distribution.
Expand Down

0 comments on commit 5ac9eaa

Please sign in to comment.