src/Entity/User.php line 24

  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\DateType;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. use Symfony\Component\HttpFoundation\File\File;
  13. use  Symfony\Component\Validator\Constraints as Assert;
  14. #[ORM\Entity(repositoryClassUserRepository::class)]
  15. #[UniqueEntity(
  16.     fields: ['email'],
  17.     errorPath'email',
  18.     message'Cet e-mail est déjà utilisée.',
  19. )]
  20. class User implements UserInterfacePasswordAuthenticatedUserInterface
  21. {
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue]
  24.     #[ORM\Column]
  25.     private ?int $id null;
  26.     #[ORM\Column(name'email'type'string'length255)]
  27.     #[Assert\Email(
  28.         message'The email {{ value }} is not a valid email.',
  29.     )]
  30.     private ?string $email null;
  31.     #[ORM\Column]
  32.     private array $roles = [];
  33.     /**
  34.      * @var string|null The hashed password
  35.      */
  36.     #[ORM\Column(type'string')]
  37.     private ?string $password null;
  38.     #[ORM\Column(length255)]
  39.     private ?string $nom null;
  40.     #[ORM\Column(length255)]
  41.     private ?string $prenom null;
  42.     #[ORM\Column(length255)]
  43.     private ?string $sexe null;
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?int $qs null;
  46.     #[ORM\Column(nullabletrue)]
  47.     private ?int $active null;
  48.     #[ORM\Column(type'string' nullabletrue)]
  49.     private $brochureFilename;
  50.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  51.     private ?\DateTimeInterface $date_naissance null;
  52.     #[ORM\ManyToOne(inversedBy'users')]
  53.     private ?Coach $coach null;
  54.     #[ORM\Column(length255nullabletrue)]
  55.     private ?string $photo null;
  56.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  57.     private ?\DateTimeInterface $date_ajout null;
  58.     #[ORM\OneToMany(mappedBy'user'targetEntityUserObjectif::class)]
  59.     private Collection $userObjectif;
  60.     #[ORM\OneToMany(mappedBy'user'targetEntityUserSport::class)]
  61.     private Collection $userSport;
  62.     #[ORM\Column(typeTypes::SMALLINTnullabletrue)]
  63.     private ?int $apt null;
  64.     #[ORM\ManyToOne(inversedBy'users')]
  65.     private ?Offre $offre null;
  66.     #[ORM\OneToMany(mappedBy'user'targetEntityCarnetEntainement::class)]
  67.     private Collection $carnetEntainements;
  68.     public function __construct()
  69.     {
  70.         $this->date_ajout = new \DateTimeImmutable();
  71.         $this->userObjectif = new ArrayCollection();
  72.         $this->userSport = new ArrayCollection();
  73.         $this->carnetEntainements = new ArrayCollection();
  74.     }
  75.     public function getId(): ?int
  76.     {
  77.         return $this->id;
  78.     }
  79.     public function getEmail(): ?string
  80.     {
  81.         return $this->email;
  82.     }
  83.     public function setEmail(string $email): self
  84.     {
  85.         $this->email $email;
  86.         return $this;
  87.     }
  88.     /**
  89.      * A visual identifier that represents this user.
  90.      *
  91.      * @see UserInterface
  92.      */
  93.     public function getUserIdentifier(): string
  94.     {
  95.         return (string) $this->email;
  96.     }
  97.     /**
  98.      * @see UserInterface
  99.      */
  100.     public function getRoles(): array
  101.     {
  102.         $roles $this->roles;
  103.         // guarantee every user at least has ROLE_USER
  104.         $roles[] = 'ROLE_USER';
  105.         return array_unique($roles);
  106.     }
  107.     public function setRoles(array $roles): self
  108.     {
  109.         $this->roles $roles;
  110.         return $this;
  111.     }
  112.     /**
  113.      * @see PasswordAuthenticatedUserInterface
  114.      */
  115.     public function getPassword(): string
  116.     {
  117.         return $this->password;
  118.     }
  119.     public function setPassword(string $password): self
  120.     {
  121.         $this->password $password;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @see UserInterface
  126.      */
  127.     public function eraseCredentials()
  128.     {
  129.         // If you store any temporary, sensitive data on the user, clear it here
  130.         // $this->plainPassword = null;
  131.     }
  132.     public function getNom(): ?string
  133.     {
  134.         return $this->nom;
  135.     }
  136.     public function setNom(string $nom): self
  137.     {
  138.         $this->nom $nom;
  139.         return $this;
  140.     }
  141.     public function getPrenom(): ?string
  142.     {
  143.         return $this->prenom;
  144.     }
  145.     public function setPrenom(string $prenom): self
  146.     {
  147.         $this->prenom $prenom;
  148.         return $this;
  149.     }
  150.     public function getSexe(): ?string
  151.     {
  152.         return $this->sexe;
  153.     }
  154.     public function setSexe(string $sexe): self
  155.     {
  156.         $this->sexe $sexe;
  157.         return $this;
  158.     }
  159.     public function getQs(): ?int
  160.     {
  161.         return $this->qs;
  162.     }
  163.     public function setQs(?int $qs): self
  164.     {
  165.         $this->qs $qs;
  166.         return $this;
  167.     }
  168.     public function getActive(): ?int
  169.     {
  170.         return $this->active;
  171.     }
  172.     public function setActive(?int $active): self
  173.     {
  174.         $this->active $active;
  175.         return $this;
  176.     }
  177.     public function getDateNaissance(): ?\DateTimeInterface
  178.     {
  179.         return $this->date_naissance;
  180.     }
  181.     public function setDateNaissance(?\DateTimeInterface $date_naissance): static
  182.     {
  183.         $this->date_naissance $date_naissance;
  184.         return $this;
  185.     }
  186.     public function getBrochureFilename(): ?string
  187.     {
  188.         return $this->brochureFilename;
  189.     }
  190.     public function setBrochureFilename(string $brochureFilename): self
  191.     {
  192.         $this->brochureFilename $brochureFilename;
  193.         return $this;
  194.     }
  195.     public function getCoach(): ?Coach
  196.     {
  197.         return $this->coach;
  198.     }
  199.     public function setCoach(?Coach $coach): static
  200.     {
  201.         $this->coach $coach;
  202.         return $this;
  203.     }
  204.     public function getPhoto(): ?string
  205.     {
  206.         return $this->photo;
  207.     }
  208.     public function setPhoto(?string $photo): static
  209.     {
  210.         $this->photo $photo;
  211.         return $this;
  212.     }
  213.     public function getDateAjout(): ?\DateTimeInterface
  214.     {
  215.         return $this->date_ajout;
  216.     }
  217.     public function setDateAjout(\DateTimeInterface $date_ajout): static
  218.     {
  219.         $this->date_ajout $date_ajout;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection<int, UserObjectif>
  224.      */
  225.     public function getUserObjectif(): Collection
  226.     {
  227.         return $this->userObjectif;
  228.     }
  229.     public function addUserObjectif(UserObjectif $userObjectif): static
  230.     {
  231.         if (!$this->userObjectif->contains($userObjectif)) {
  232.             $this->userObjectif->add($userObjectif);
  233.             $userObjectif->setUser($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeUserObjectif(UserObjectif $userObjectif): static
  238.     {
  239.         if ($this->userObjectif->removeElement($userObjectif)) {
  240.             // set the owning side to null (unless already changed)
  241.             if ($userObjectif->getUser() === $this) {
  242.                 $userObjectif->setUser(null);
  243.             }
  244.         }
  245.         return $this;
  246.     }
  247.     /**
  248.      * @return Collection<int, UserSport>
  249.      */
  250.     public function getUserSport(): Collection
  251.     {
  252.         return $this->userSport;
  253.     }
  254.     public function addUserSport(UserSport $userSport): static
  255.     {
  256.         if (!$this->userSport->contains($userSport)) {
  257.             $this->userSport->add($userSport);
  258.             $userSport->setUser($this);
  259.         }
  260.         return $this;
  261.     }
  262.     public function removeUserSport(UserSport $userSport): static
  263.     {
  264.         if ($this->userSport->removeElement($userSport)) {
  265.             // set the owning side to null (unless already changed)
  266.             if ($userSport->getUser() === $this) {
  267.                 $userSport->setUser(null);
  268.             }
  269.         }
  270.         return $this;
  271.     }
  272.     public function getApt(): ?int
  273.     {
  274.         return $this->apt;
  275.     }
  276.     public function setApt(?int $apt): static
  277.     {
  278.         $this->apt $apt;
  279.         return $this;
  280.     }
  281.     public function getOffre(): ?Offre
  282.     {
  283.         return $this->offre;
  284.     }
  285.     public function setOffre(?Offre $offre): static
  286.     {
  287.         $this->offre $offre;
  288.         return $this;
  289.     }
  290.     /**
  291.      * @return Collection<int, CarnetEntainement>
  292.      */
  293.     public function getCarnetEntainements(): Collection
  294.     {
  295.         return $this->carnetEntainements;
  296.     }
  297.     public function addCarnetEntainement(CarnetEntainement $carnetEntainement): static
  298.     {
  299.         if (!$this->carnetEntainements->contains($carnetEntainement)) {
  300.             $this->carnetEntainements->add($carnetEntainement);
  301.             $carnetEntainement->setUser($this);
  302.         }
  303.         return $this;
  304.     }
  305.     public function removeCarnetEntainement(CarnetEntainement $carnetEntainement): static
  306.     {
  307.         if ($this->carnetEntainements->removeElement($carnetEntainement)) {
  308.             // set the owning side to null (unless already changed)
  309.             if ($carnetEntainement->getUser() === $this) {
  310.                 $carnetEntainement->setUser(null);
  311.             }
  312.         }
  313.         return $this;
  314.     }
  315. }