I have an Entity that has a the following schema:
id, name, ..., startDate, endDate
I've also added a calculated field in my entity that gives me the status:
public function getStatus() {
if (new \DateTime() < $this->getStartDate()) {
return 'planned';
}
if (new \DateTime() > $this->getEndDate()) {
return 'expired';
}
return 'published';
}
What I would like to do is be able to create a filter on this field. I can't seem to find it in the documentation. I've tried creating a filter on it the same way i create filters on other fields, however it doesn't appear in my swagger UI interface.
// config/services.yaml
services:
...
view.search_filter:
parent: 'api_platform.doctrine.orm.search_filter'
arguments:
$properties:
id: 'exact'
name: 'ipartial'
...
status: 'exact' // doesn't seem to work
tags: [ 'api_platform.filter' ]
...
I've also checked out the documentation on writing custom filters, but from what I've seen it has to be an existing property.