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(repositoryClass: UserRepository::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 UserInterface, PasswordAuthenticatedUserInterface
  19. {
  20.     #[ORM\Id]
  21.     #[ORM\GeneratedValue]
  22.     #[ORM\Column]
  23.     private ?int $id = null;
  24.     #[ORM\Column(length: 180, unique: true)]
  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(targetEntity: Formation::class, mappedBy: "formateur")]
  34.     private Collection $formations;
  35.     #[ORM\Column(length: 70, nullable: true)]
  36.     private ?string $firstName = null;
  37.     #[ORM\Column(length: 70, nullable: true)]
  38.     private ?string $lastName = null;
  39.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  40.     private ?string $phone = null;
  41.     #[ORM\Column(length: 70, nullable: true)]
  42.     private ?string $functionFormateur = null;
  43.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  44.     private ?string $linkFormateur = null;
  45.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  46.     private ?string $signature = null;
  47.     #[ORM\Column(name: 'trainer_attendance_date', type: Types::DATE_MUTABLE, nullable: true)]
  48.     private ?\DateTimeInterface $trainerAttendanceDate = null;
  49.     #[ORM\Column(name: 'trainer_attendance_period', length: 100, nullable: true)]
  50.     private ?string $trainerAttendancePeriod = null;
  51.     #[ORM\Column(name: 'trainer_attendance_company', length: 255, nullable: true)]
  52.     private ?string $trainerAttendanceCompany = null;
  53.     #[ORM\Column(name: 'trainer_attendance_comments', type: Types::TEXT, nullable: true)]
  54.     private ?string $trainerAttendanceComments = null;
  55.     #[ORM\Column(name: 'trainer_attendance_signed_at', type: Types::DATETIME_MUTABLE, nullable: true)]
  56.     private ?\DateTimeInterface $trainerAttendanceSignedAt = null;
  57.     #[ORM\Column(type: 'boolean', nullable: true)]
  58.     private ?bool $isSigNumeric = true;
  59.     public function __construct()
  60.     {
  61.         $this->formations = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getEmail(): ?string
  68.     {
  69.         return $this->email;
  70.     }
  71.     public function setEmail(string $email): self
  72.     {
  73.         $this->email = $email;
  74.         return $this;
  75.     }
  76.     /**
  77.      * A visual identifier that represents this user.
  78.      *
  79.      * @see UserInterface
  80.      */
  81.     public function getUserIdentifier(): string
  82.     {
  83.         return (string) $this->email;
  84.     }
  85.     /**
  86.      * @see UserInterface
  87.      */
  88.     public function getRoles(): array
  89.     {
  90.         $roles = $this->roles;
  91.         // guarantee every user at least has ROLE_USER
  92.         $roles[] = 'ROLE_USER';
  93.         return array_unique($roles);
  94.     }
  95.     public function setRoles(array $roles): self
  96.     {
  97.         $this->roles = $roles;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @see PasswordAuthenticatedUserInterface
  102.      */
  103.     public function getPassword(): string
  104.     {
  105.         return $this->password;
  106.     }
  107.     public function setPassword(string $password): self
  108.     {
  109.         $this->password = $password;
  110.         return $this;
  111.     }
  112.     /**
  113.      * @see UserInterface
  114.      */
  115.     public function eraseCredentials()
  116.     {
  117.         // If you store any temporary, sensitive data on the user, clear it here
  118.         // $this->plainPassword = null;
  119.     }
  120.     /**
  121.      * @return Collection<int, Formation>
  122.      */
  123.     public function getFormation(): Collection
  124.     {
  125.         return $this->formations;
  126.     }
  127.     public function addFormation(Formation $formations): self
  128.     {
  129.         if (!$this->formations->contains($formations)) {
  130.             $this->formations->add($formations);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeFormation(Formation $formations): self
  135.     {
  136.         $this->formations->removeElement($formations);
  137.         return $this;
  138.     }
  139.     public function getFirstName(): ?string
  140.     {
  141.         return $this->firstName;
  142.     }
  143.     public function setFirstName(?string $firstName): self
  144.     {
  145.         $this->firstName = $firstName;
  146.         return $this;
  147.     }
  148.     public function getLastName(): ?string
  149.     {
  150.         return $this->lastName;
  151.     }
  152.     public function setLastName(?string $lastName): self
  153.     {
  154.         $this->lastName = $lastName;
  155.         return $this;
  156.     }
  157.     public function getPhone(): ?string
  158.     {
  159.         return $this->phone;
  160.     }
  161.     public function setPhone(?string $phone): self
  162.     {
  163.         $this->phone = $phone;
  164.         return $this;
  165.     }
  166.     public function getFunctionFormateur(): ?string
  167.     {
  168.         return $this->functionFormateur;
  169.     }
  170.     public function setFunctionFormateur(?string $functionFormateur): self
  171.     {
  172.         $this->functionFormateur = $functionFormateur;
  173.         return $this;
  174.     }
  175.     public function getLinkFormateur(): ?string
  176.     {
  177.         return $this->linkFormateur;
  178.     }
  179.     public function setLinkFormateur(?string $linkFormateur): self
  180.     {
  181.         $this->linkFormateur = $linkFormateur;
  182.         return $this;
  183.     }
  184.     public function getSignature(): ?string
  185.     {
  186.         return $this->signature;
  187.     }
  188.     public function setSignature(?string $signature): self
  189.     {
  190.         $this->signature = $signature;
  191.         return $this;
  192.     }
  193.     public function getTrainerAttendanceDate(): ?\DateTimeInterface
  194.     {
  195.         return $this->trainerAttendanceDate;
  196.     }
  197.     public function setTrainerAttendanceDate(?\DateTimeInterface $date): self
  198.     {
  199.         $this->trainerAttendanceDate = $date;
  200.         return $this;
  201.     }
  202.     public function getTrainerAttendancePeriod(): ?string
  203.     {
  204.         return $this->trainerAttendancePeriod;
  205.     }
  206.     public function setTrainerAttendancePeriod(?string $period): self
  207.     {
  208.         $this->trainerAttendancePeriod = $period;
  209.         return $this;
  210.     }
  211.     public function getTrainerAttendanceCompany(): ?string
  212.     {
  213.         return $this->trainerAttendanceCompany;
  214.     }
  215.     public function setTrainerAttendanceCompany(?string $company): self
  216.     {
  217.         $this->trainerAttendanceCompany = $company;
  218.         return $this;
  219.     }
  220.     public function getTrainerAttendanceComments(): ?string
  221.     {
  222.         return $this->trainerAttendanceComments;
  223.     }
  224.     public function setTrainerAttendanceComments(?string $comments): self
  225.     {
  226.         $this->trainerAttendanceComments = $comments;
  227.         return $this;
  228.     }
  229.     public function getTrainerAttendanceSignedAt(): ?\DateTimeInterface
  230.     {
  231.         return $this->trainerAttendanceSignedAt;
  232.     }
  233.     public function setTrainerAttendanceSignedAt(?\DateTimeInterface $signedAt): self
  234.     {
  235.         $this->trainerAttendanceSignedAt = $signedAt;
  236.         return $this;
  237.     }
  238.     /**
  239.      * @return bool|null
  240.      */
  241.     public function getIsSigNumeric(): ?bool
  242.     {
  243.         return $this->isSigNumeric;
  244.     }
  245.     /**
  246.      * @param bool $isSigNumeric
  247.      * @return $this
  248.      */
  249.     public function setIsSigNumeric(bool $isSigNumeric): self
  250.     {
  251.         $this->isSigNumeric = $isSigNumeric;
  252.         return $this;
  253.     }
  254. }