I'm trying to apply SearchFilter to multiple resources.
Let's imagine I've got two resources: Post
and Article
(just for the illustration):
#[ApiRsource]
class Post
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $postDescription = null;
...
}
#[ApiRsource]
class Article
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $articleDescription = null;
...
}
I want to add a unique endpoint /search?q=key
that will return Post
and Article
resources with a postDescription
/articleDescription
containing key
.
Is there a way to do this without resorting to inheritance?