src/Entity/User.php line 21

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. use Doctrine\ORM\Mapping\DiscriminatorMap;
  12. use Doctrine\ORM\Mapping\InheritanceType;
  13. use Doctrine\ORM\Mapping\DiscriminatorColumn;
  14. #[ORM\Entity(repositoryClassUserRepository::class)]
  15. #[InheritanceType("JOINED")]
  16. #[DiscriminatorColumn(name"type"type"string")]
  17. #[UniqueEntity(fields: ['email'], message'Il existe déjà un compte avec cette email')]
  18. class User implements UserInterfacePasswordAuthenticatedUserInterface
  19. {
  20.     #[ORM\Id]
  21.     #[ORM\GeneratedValue]
  22.     #[ORM\Column]
  23.     private ?int $id null;
  24.     #[ORM\Column(length180uniquetrue)]
  25.     private ?string $email null;
  26.     #[ORM\Column]
  27.     private array $roles = [];
  28.     /**
  29.      * @var string The hashed password
  30.      */
  31.     #[ORM\Column]
  32.     private ?string $password null;
  33.     #[ORM\OneToMany(targetEntityFormation::class, mappedBy"formateur")]
  34.     private Collection $formations;
  35.     #[ORM\Column(length70nullabletrue)]
  36.     private ?string $firstName null;
  37.     #[ORM\Column(length70nullabletrue)]
  38.     private ?string $lastName null;
  39.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  40.     private ?string $phone null;
  41.     #[ORM\Column(length70nullabletrue)]
  42.     private ?string $functionFormateur null;
  43.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  44.     private ?string $linkFormateur null;
  45.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  46.     private ?string $signature null;
  47.     public function __construct()
  48.     {
  49.         $this->formations = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getEmail(): ?string
  56.     {
  57.         return $this->email;
  58.     }
  59.     public function setEmail(string $email): self
  60.     {
  61.         $this->email $email;
  62.         return $this;
  63.     }
  64.     /**
  65.      * A visual identifier that represents this user.
  66.      *
  67.      * @see UserInterface
  68.      */
  69.     public function getUserIdentifier(): string
  70.     {
  71.         return (string) $this->email;
  72.     }
  73.     /**
  74.      * @see UserInterface
  75.      */
  76.     public function getRoles(): array
  77.     {
  78.         $roles $this->roles;
  79.         // guarantee every user at least has ROLE_USER
  80.         $roles[] = 'ROLE_USER';
  81.         return array_unique($roles);
  82.     }
  83.     public function setRoles(array $roles): self
  84.     {
  85.         $this->roles $roles;
  86.         return $this;
  87.     }
  88.     /**
  89.      * @see PasswordAuthenticatedUserInterface
  90.      */
  91.     public function getPassword(): string
  92.     {
  93.         return $this->password;
  94.     }
  95.     public function setPassword(string $password): self
  96.     {
  97.         $this->password $password;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @see UserInterface
  102.      */
  103.     public function eraseCredentials()
  104.     {
  105.         // If you store any temporary, sensitive data on the user, clear it here
  106.         // $this->plainPassword = null;
  107.     }
  108.     /**
  109.      * @return Collection<int, Formation>
  110.      */
  111.     public function getFormation(): Collection
  112.     {
  113.         return $this->formations;
  114.     }
  115.     public function addFormation(Formation $formations): self
  116.     {
  117.         if (!$this->formations->contains($formations)) {
  118.             $this->formations->add($formations);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeFormation(Formation $formations): self
  123.     {
  124.         $this->formations->removeElement($formations);
  125.         return $this;
  126.     }
  127.     public function getFirstName(): ?string
  128.     {
  129.         return $this->firstName;
  130.     }
  131.     public function setFirstName(?string $firstName): self
  132.     {
  133.         $this->firstName $firstName;
  134.         return $this;
  135.     }
  136.     public function getLastName(): ?string
  137.     {
  138.         return $this->lastName;
  139.     }
  140.     public function setLastName(?string $lastName): self
  141.     {
  142.         $this->lastName $lastName;
  143.         return $this;
  144.     }
  145.     public function getPhone(): ?string
  146.     {
  147.         return $this->phone;
  148.     }
  149.     public function setPhone(?string $phone): self
  150.     {
  151.         $this->phone $phone;
  152.         return $this;
  153.     }
  154.     public function getFunctionFormateur(): ?string
  155.     {
  156.         return $this->functionFormateur;
  157.     }
  158.     public function setFunctionFormateur(?string $functionFormateur): self
  159.     {
  160.         $this->functionFormateur $functionFormateur;
  161.         return $this;
  162.     }
  163.     public function getLinkFormateur(): ?string
  164.     {
  165.         return $this->linkFormateur;
  166.     }
  167.     public function setLinkFormateur(?string $linkFormateur): self
  168.     {
  169.         $this->linkFormateur $linkFormateur;
  170.         return $this;
  171.     }
  172.     public function getSignature(): ?string
  173.     {
  174.         return $this->signature;
  175.     }
  176.     public function setSignature(?string $signature): self
  177.     {
  178.         $this->signature $signature;
  179.         return $this;
  180.     }
  181. }