Many-To-One with multiple target entities
You can create a (abstract) mapped superclass called Food
, which can hold some basic information for Fruit
and Vegetable
.
The keyword for your question is inheritance mapping
, this is the documentation for it: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html#inheritance-mapping
Then you could reference this mapped superclass in your entity relationship.