api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.45k stars 879 forks source link

feat(doctrine): doctrine filters like laravel eloquent filters #6775

Open vinceAmstoutz opened 3 weeks ago

vinceAmstoutz commented 3 weeks ago
Q A
Branch? main
License MIT
Doc PR Coming soon

Completes #6749.

Goal:

Using Dotrine filters as we use Laravel Eloquent filters. Example using a BooleanFilter with Symfony and Doctrine:

#[ApiResource]
#[GetCollection(
    parameters: [
        'active' => new QueryParameter(
            filter: new BooleanFilter(),
        ),

        // support also for filter aliasing
        'enabled' => new QueryParameter(
            filter: new BooleanFilter(),
            property: 'active',
        ),
    ],
)]
#[ORM\Entity]
class FilteredBooleanParameter {
    // ...
}

TODO:

Will be done in another PR:

vinceAmstoutz commented 2 weeks ago

@soyuka As requested, the swagger UI doc looks like this for the DateFilter: image

vinceAmstoutz commented 2 weeks ago

@soyuka As requested, the swagger UI doc looks like this for the RangeFilter:

image