I am using the Table Inheritance class with Doctrine to make the Doctors
class inherit the properties of the Users
class. The Users
class has an @ORM\ManyToMany
relation implemented to the Doctors
class. Here is the code for the two classes:
#[ORM\Entity(repositoryClass: UsersRepository::class)]
#[UniqueEntity(fields: ['email'], message: 'il existe déja un compte avec cet email')]
#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap(['patient' =>Users::class, 'doctor'=>Doctors::class])]
class Users implements UserInterface, PasswordAuthenticatedUserInterface
{
}
#[ORM\Entity(repositoryClass: DoctorsRepository::class)]
class Doctors extends Users
{
}
However, after making a registration, when I dd()
the Doctors
entity, I get a second ID in the properties which is null. Here is the image of the result:
dd of entity doctors
PS: everything is fine in the database. I have all the data
All the data of the entity is available except for the ID of Doctors
. Any ideas on how to solve this problem and get the ID of my Doctors
entity?