What is the best way to have the same entity fields in many entities? For example, "Related Entities" will appear in 8 tables.
class User { #[ORM\Column(length: 255)] private ?string $relatedEntity = null; }
class User2 { #[ORM\Column(length: 255)] private ?string $relatedEntity = null; }
RelatedEntity in "User" is like a parent field for others. Is there any way to map them to each other to make querying simpler?
I tried OneToOne but every time it adds new users but I don't need to do that.
You have a few options, you can use traits a> or use abstract classes. Like @LBA said in his answer, if your entities have a lot in common and only a few differences, you might want to look into inheritance mapping.
Feature example:
Abstract class example: