src/Entity/User.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\UserRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  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. #[ORM\Entity(repositoryClassUserRepository::class)]
  13. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  14. #[ApiResource]
  15. class User implements UserInterfacePasswordAuthenticatedUserInterface
  16. {
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column]
  20.     private ?int $id null;
  21.     #[ORM\Column(length180uniquetrue)]
  22.     private ?string $email null;
  23.     #[ORM\Column]
  24.     private array $roles = [];
  25.     /**
  26.      * @var string The hashed password
  27.      */
  28.     #[ORM\Column]
  29.     private ?string $password null;
  30.     #[ORM\Column(length255nullabletrue)]
  31.     private ?string $nom null;
  32.     #[ORM\Column(length255nullabletrue)]
  33.     private ?string $prenom null;
  34.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  35.     private ?\DateTimeInterface $dateNaissance null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     private ?string $photo null;
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?int $age null;
  40.     #[ORM\Column(length255nullabletrue)]
  41.     private ?string $tel null;
  42.     #[ORM\Column(length255nullabletrue)]
  43.     private ?string $adresse null;
  44.     #[ORM\Column(length255nullabletrue)]
  45.     private ?string $tel2 null;
  46.     #[ORM\ManyToOne(inversedBy'etudiants')]
  47.     private ?Classe $classe null;
  48.     #[ORM\ManyToOne(inversedBy'etudiants')]
  49.     private ?Niveau $niveau null;
  50.     #[ORM\ManyToOne(inversedBy'enseignants')]
  51.     private ?Grade $grade null;
  52.     #[ORM\OneToMany(targetEntityAffectationEtudiant::class, mappedBy'etudiant',cascade: ['remove'])]
  53.     private Collection $affectationEtudiants;
  54.     #[ORM\Column(length255nullabletrue)]
  55.     private ?string $situation null;
  56.     #[ORM\OneToMany(targetEntityDepartement::class, mappedBy'directeur',cascade: ['remove'])]
  57.     private Collection $departements;
  58.     #[ORM\OneToMany(targetEntityAffectationEnseignant::class, mappedBy'enseignant',cascade: ['remove'])]
  59.     private Collection $affectationEnseignants;
  60.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  61.     private ?string $biographie null;
  62.     #[ORM\OneToMany(targetEntityFeuillePresence::class, mappedBy'enseignant',cascade: ['remove'])]
  63.     private Collection $feuillePresences;
  64.     #[ORM\OneToMany(targetEntityPresenceEtudiant::class, mappedBy'etudiant',cascade: ['remove'])]
  65.     private Collection $presenceEtudiants;
  66.     #[ORM\OneToMany(targetEntitySurveillance::class, mappedBy'enseignants')]
  67.     private Collection $surveillances;
  68.     public function __construct()
  69.     {
  70.         $this->affectationEtudiants = new ArrayCollection();
  71.         $this->departements = new ArrayCollection();
  72.         $this->affectationEnseignants = new ArrayCollection();
  73.         $this->feuillePresences = new ArrayCollection();
  74.         $this->presenceEtudiants = new ArrayCollection();
  75.         $this->surveillances = new ArrayCollection();
  76.     }
  77.     public function getId(): ?int
  78.     {
  79.         return $this->id;
  80.     }
  81.     public function getEmail(): ?string
  82.     {
  83.         return $this->email;
  84.     }
  85.     public function setEmail(string $email): static
  86.     {
  87.         $this->email $email;
  88.         return $this;
  89.     }
  90.     /**
  91.      * A visual identifier that represents this user.
  92.      *
  93.      * @see UserInterface
  94.      */
  95.     public function getUserIdentifier(): string
  96.     {
  97.         return (string) $this->email;
  98.     }
  99.     /**
  100.      * @see UserInterface
  101.      */
  102.     public function getRoles(): array
  103.     {
  104.         $roles $this->roles;
  105.         // guarantee every user at least has ROLE_USER
  106.         $roles[] = 'ROLE_USER';
  107.         return array_unique($roles);
  108.     }
  109.     public function setRoles(array $roles): static
  110.     {
  111.         $this->roles $roles;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @see PasswordAuthenticatedUserInterface
  116.      */
  117.     public function getPassword(): string
  118.     {
  119.         return $this->password;
  120.     }
  121.     public function setPassword(string $password): static
  122.     {
  123.         $this->password $password;
  124.         return $this;
  125.     }
  126.     /**
  127.      * @see UserInterface
  128.      */
  129.     public function eraseCredentials(): void
  130.     {
  131.         // If you store any temporary, sensitive data on the user, clear it here
  132.         // $this->plainPassword = null;
  133.     }
  134.     public function getNom(): ?string
  135.     {
  136.         return $this->nom;
  137.     }
  138.     public function setNom(?string $nom): static
  139.     {
  140.         $this->nom $nom;
  141.         return $this;
  142.     }
  143.     public function getPrenom(): ?string
  144.     {
  145.         return $this->prenom;
  146.     }
  147.     public function setPrenom(?string $prenom): static
  148.     {
  149.         $this->prenom $prenom;
  150.         return $this;
  151.     }
  152.     public function getDateNaissance(): ?\DateTimeInterface
  153.     {
  154.         return $this->dateNaissance;
  155.     }
  156.     public function setDateNaissance(?\DateTimeInterface $dateNaissance): static
  157.     {
  158.         $this->dateNaissance $dateNaissance;
  159.         return $this;
  160.     }
  161.     public function getPhoto(): ?string
  162.     {
  163.         return $this->photo;
  164.     }
  165.     public function setPhoto(?string $photo): static
  166.     {
  167.         $this->photo $photo;
  168.         return $this;
  169.     }
  170.     public function getAge(): ?int
  171.     {
  172.         return $this->age;
  173.     }
  174.     public function setAge(?int $age): static
  175.     {
  176.         $this->age $age;
  177.         return $this;
  178.     }
  179.     public function getTel(): ?string
  180.     {
  181.         return $this->tel;
  182.     }
  183.     public function setTel(?string $tel): static
  184.     {
  185.         $this->tel $tel;
  186.         return $this;
  187.     }
  188.     public function getAdresse(): ?string
  189.     {
  190.         return $this->adresse;
  191.     }
  192.     public function setAdresse(?string $adresse): static
  193.     {
  194.         $this->adresse $adresse;
  195.         return $this;
  196.     }
  197.     public function getTel2(): ?string
  198.     {
  199.         return $this->tel2;
  200.     }
  201.     public function setTel2(?string $tel2): static
  202.     {
  203.         $this->tel2 $tel2;
  204.         return $this;
  205.     }
  206.     public function getClasse(): ?Classe
  207.     {
  208.         return $this->classe;
  209.     }
  210.     public function setClasse(?Classe $classe): static
  211.     {
  212.         $this->classe $classe;
  213.         return $this;
  214.     }
  215.     public function getNiveau(): ?Niveau
  216.     {
  217.         return $this->niveau;
  218.     }
  219.     public function setNiveau(?Niveau $niveau): static
  220.     {
  221.         $this->niveau $niveau;
  222.         return $this;
  223.     }
  224.     public function getGrade(): ?Grade
  225.     {
  226.         return $this->grade;
  227.     }
  228.     public function setGrade(?Grade $grade): static
  229.     {
  230.         $this->grade $grade;
  231.         return $this;
  232.     }
  233.     /**
  234.      * @return Collection<int, AffectationEtudiant>
  235.      */
  236.     public function getAffectationEtudiants(): Collection
  237.     {
  238.         return $this->affectationEtudiants;
  239.     }
  240.     public function addAffectationEtudiant(AffectationEtudiant $affectationEtudiant): static
  241.     {
  242.         if (!$this->affectationEtudiants->contains($affectationEtudiant)) {
  243.             $this->affectationEtudiants->add($affectationEtudiant);
  244.             $affectationEtudiant->setEtudiant($this);
  245.         }
  246.         return $this;
  247.     }
  248.     public function removeAffectationEtudiant(AffectationEtudiant $affectationEtudiant): static
  249.     {
  250.         if ($this->affectationEtudiants->removeElement($affectationEtudiant)) {
  251.             // set the owning side to null (unless already changed)
  252.             if ($affectationEtudiant->getEtudiant() === $this) {
  253.                 $affectationEtudiant->setEtudiant(null);
  254.             }
  255.         }
  256.         return $this;
  257.     }
  258.     public function getSituation(): ?string
  259.     {
  260.         return $this->situation;
  261.     }
  262.     public function setSituation(?string $situation): static
  263.     {
  264.         $this->situation $situation;
  265.         return $this;
  266.     }
  267.     /**
  268.      * @return Collection<int, Departement>
  269.      */
  270.     public function getDepartements(): Collection
  271.     {
  272.         return $this->departements;
  273.     }
  274.     public function addDepartement(Departement $departement): static
  275.     {
  276.         if (!$this->departements->contains($departement)) {
  277.             $this->departements->add($departement);
  278.             $departement->setDirecteur($this);
  279.         }
  280.         return $this;
  281.     }
  282.     public function removeDepartement(Departement $departement): static
  283.     {
  284.         if ($this->departements->removeElement($departement)) {
  285.             // set the owning side to null (unless already changed)
  286.             if ($departement->getDirecteur() === $this) {
  287.                 $departement->setDirecteur(null);
  288.             }
  289.         }
  290.         return $this;
  291.     }
  292.     /**
  293.      * @return Collection<int, AffectationEnseignant>
  294.      */
  295.     public function getAffectationEnseignants(): Collection
  296.     {
  297.         return $this->affectationEnseignants;
  298.     }
  299.     public function addAffectationEnseignant(AffectationEnseignant $affectationEnseignant): static
  300.     {
  301.         if (!$this->affectationEnseignants->contains($affectationEnseignant)) {
  302.             $this->affectationEnseignants->add($affectationEnseignant);
  303.             $affectationEnseignant->setEnseignant($this);
  304.         }
  305.         return $this;
  306.     }
  307.     public function removeAffectationEnseignant(AffectationEnseignant $affectationEnseignant): static
  308.     {
  309.         if ($this->affectationEnseignants->removeElement($affectationEnseignant)) {
  310.             // set the owning side to null (unless already changed)
  311.             if ($affectationEnseignant->getEnseignant() === $this) {
  312.                 $affectationEnseignant->setEnseignant(null);
  313.             }
  314.         }
  315.         return $this;
  316.     }
  317.     public function getBiographie(): ?string
  318.     {
  319.         return $this->biographie;
  320.     }
  321.     public function setBiographie(?string $biographie): static
  322.     {
  323.         $this->biographie $biographie;
  324.         return $this;
  325.     }
  326.     /**
  327.      * @return Collection<int, FeuillePresence>
  328.      */
  329.     public function getFeuillePresences(): Collection
  330.     {
  331.         return $this->feuillePresences;
  332.     }
  333.     public function addFeuillePresence(FeuillePresence $feuillePresence): static
  334.     {
  335.         if (!$this->feuillePresences->contains($feuillePresence)) {
  336.             $this->feuillePresences->add($feuillePresence);
  337.             $feuillePresence->setEnseignant($this);
  338.         }
  339.         return $this;
  340.     }
  341.     public function removeFeuillePresence(FeuillePresence $feuillePresence): static
  342.     {
  343.         if ($this->feuillePresences->removeElement($feuillePresence)) {
  344.             // set the owning side to null (unless already changed)
  345.             if ($feuillePresence->getEnseignant() === $this) {
  346.                 $feuillePresence->setEnseignant(null);
  347.             }
  348.         }
  349.         return $this;
  350.     }
  351.     /**
  352.      * @return Collection<int, PresenceEtudiant>
  353.      */
  354.     public function getPresenceEtudiants(): Collection
  355.     {
  356.         return $this->presenceEtudiants;
  357.     }
  358.     public function addPresenceEtudiant(PresenceEtudiant $presenceEtudiant): static
  359.     {
  360.         if (!$this->presenceEtudiants->contains($presenceEtudiant)) {
  361.             $this->presenceEtudiants->add($presenceEtudiant);
  362.             $presenceEtudiant->setEtudiant($this);
  363.         }
  364.         return $this;
  365.     }
  366.     public function removePresenceEtudiant(PresenceEtudiant $presenceEtudiant): static
  367.     {
  368.         if ($this->presenceEtudiants->removeElement($presenceEtudiant)) {
  369.             // set the owning side to null (unless already changed)
  370.             if ($presenceEtudiant->getEtudiant() === $this) {
  371.                 $presenceEtudiant->setEtudiant(null);
  372.             }
  373.         }
  374.         return $this;
  375.     }
  376.     /**
  377.      * @return Collection<int, Surveillance>
  378.      */
  379.     public function getSurveillances(): Collection
  380.     {
  381.         return $this->surveillances;
  382.     }
  383.     public function addSurveillance(Surveillance $surveillance): static
  384.     {
  385.         if (!$this->surveillances->contains($surveillance)) {
  386.             $this->surveillances->add($surveillance);
  387.             $surveillance->setEnseignants($this);
  388.         }
  389.         return $this;
  390.     }
  391.     public function removeSurveillance(Surveillance $surveillance): static
  392.     {
  393.         if ($this->surveillances->removeElement($surveillance)) {
  394.             // set the owning side to null (unless already changed)
  395.             if ($surveillance->getEnseignants() === $this) {
  396.                 $surveillance->setEnseignants(null);
  397.             }
  398.         }
  399.         return $this;
  400.     }
  401. }