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.     public function __construct()
  67.     {
  68.         $this->affectationEtudiants = new ArrayCollection();
  69.         $this->departements = new ArrayCollection();
  70.         $this->affectationEnseignants = new ArrayCollection();
  71.         $this->feuillePresences = new ArrayCollection();
  72.         $this->presenceEtudiants = new ArrayCollection();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getEmail(): ?string
  79.     {
  80.         return $this->email;
  81.     }
  82.     public function setEmail(string $email): static
  83.     {
  84.         $this->email $email;
  85.         return $this;
  86.     }
  87.     /**
  88.      * A visual identifier that represents this user.
  89.      *
  90.      * @see UserInterface
  91.      */
  92.     public function getUserIdentifier(): string
  93.     {
  94.         return (string) $this->email;
  95.     }
  96.     /**
  97.      * @see UserInterface
  98.      */
  99.     public function getRoles(): array
  100.     {
  101.         $roles $this->roles;
  102.         // guarantee every user at least has ROLE_USER
  103.         $roles[] = 'ROLE_USER';
  104.         return array_unique($roles);
  105.     }
  106.     public function setRoles(array $roles): static
  107.     {
  108.         $this->roles $roles;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @see PasswordAuthenticatedUserInterface
  113.      */
  114.     public function getPassword(): string
  115.     {
  116.         return $this->password;
  117.     }
  118.     public function setPassword(string $password): static
  119.     {
  120.         $this->password $password;
  121.         return $this;
  122.     }
  123.     /**
  124.      * @see UserInterface
  125.      */
  126.     public function eraseCredentials(): void
  127.     {
  128.         // If you store any temporary, sensitive data on the user, clear it here
  129.         // $this->plainPassword = null;
  130.     }
  131.     public function getNom(): ?string
  132.     {
  133.         return $this->nom;
  134.     }
  135.     public function setNom(?string $nom): static
  136.     {
  137.         $this->nom $nom;
  138.         return $this;
  139.     }
  140.     public function getPrenom(): ?string
  141.     {
  142.         return $this->prenom;
  143.     }
  144.     public function setPrenom(?string $prenom): static
  145.     {
  146.         $this->prenom $prenom;
  147.         return $this;
  148.     }
  149.     public function getDateNaissance(): ?\DateTimeInterface
  150.     {
  151.         return $this->dateNaissance;
  152.     }
  153.     public function setDateNaissance(?\DateTimeInterface $dateNaissance): static
  154.     {
  155.         $this->dateNaissance $dateNaissance;
  156.         return $this;
  157.     }
  158.     public function getPhoto(): ?string
  159.     {
  160.         return $this->photo;
  161.     }
  162.     public function setPhoto(?string $photo): static
  163.     {
  164.         $this->photo $photo;
  165.         return $this;
  166.     }
  167.     public function getAge(): ?int
  168.     {
  169.         return $this->age;
  170.     }
  171.     public function setAge(?int $age): static
  172.     {
  173.         $this->age $age;
  174.         return $this;
  175.     }
  176.     public function getTel(): ?string
  177.     {
  178.         return $this->tel;
  179.     }
  180.     public function setTel(?string $tel): static
  181.     {
  182.         $this->tel $tel;
  183.         return $this;
  184.     }
  185.     public function getAdresse(): ?string
  186.     {
  187.         return $this->adresse;
  188.     }
  189.     public function setAdresse(?string $adresse): static
  190.     {
  191.         $this->adresse $adresse;
  192.         return $this;
  193.     }
  194.     public function getTel2(): ?string
  195.     {
  196.         return $this->tel2;
  197.     }
  198.     public function setTel2(?string $tel2): static
  199.     {
  200.         $this->tel2 $tel2;
  201.         return $this;
  202.     }
  203.     public function getClasse(): ?Classe
  204.     {
  205.         try {
  206.             if ($this->classe) {
  207.                 // Ensure the proxy is initialized to catch missing DB rows
  208.                 $this->classe->getLibelle();
  209.             }
  210.             return $this->classe;
  211.         } catch (\Doctrine\ORM\EntityNotFoundException $e) {
  212.             return null;
  213.         }
  214.     }
  215.     public function setClasse(?Classe $classe): static
  216.     {
  217.         $this->classe $classe;
  218.         return $this;
  219.     }
  220.     public function getNiveau(): ?Niveau
  221.     {
  222.         try {
  223.             if ($this->niveau) {
  224.                 $this->niveau->getLibelle();
  225.             }
  226.             return $this->niveau;
  227.         } catch (\Doctrine\ORM\EntityNotFoundException $e) {
  228.             return null;
  229.         }
  230.     }
  231.     public function setNiveau(?Niveau $niveau): static
  232.     {
  233.         $this->niveau $niveau;
  234.         return $this;
  235.     }
  236.     public function getGrade(): ?Grade
  237.     {
  238.         try {
  239.             if ($this->grade) {
  240.                 $this->grade->getLibelle();
  241.             }
  242.             return $this->grade;
  243.         } catch (\Doctrine\ORM\EntityNotFoundException $e) {
  244.             return null;
  245.         }
  246.     }
  247.     public function setGrade(?Grade $grade): static
  248.     {
  249.         $this->grade $grade;
  250.         return $this;
  251.     }
  252.     /**
  253.      * @return Collection<int, AffectationEtudiant>
  254.      */
  255.     public function getAffectationEtudiants(): Collection
  256.     {
  257.         return $this->affectationEtudiants;
  258.     }
  259.     public function addAffectationEtudiant(AffectationEtudiant $affectationEtudiant): static
  260.     {
  261.         if (!$this->affectationEtudiants->contains($affectationEtudiant)) {
  262.             $this->affectationEtudiants->add($affectationEtudiant);
  263.             $affectationEtudiant->setEtudiant($this);
  264.         }
  265.         return $this;
  266.     }
  267.     public function removeAffectationEtudiant(AffectationEtudiant $affectationEtudiant): static
  268.     {
  269.         if ($this->affectationEtudiants->removeElement($affectationEtudiant)) {
  270.             // set the owning side to null (unless already changed)
  271.             if ($affectationEtudiant->getEtudiant() === $this) {
  272.                 $affectationEtudiant->setEtudiant(null);
  273.             }
  274.         }
  275.         return $this;
  276.     }
  277.     public function getSituation(): ?string
  278.     {
  279.         return $this->situation;
  280.     }
  281.     public function setSituation(?string $situation): static
  282.     {
  283.         $this->situation $situation;
  284.         return $this;
  285.     }
  286.     /**
  287.      * @return Collection<int, Departement>
  288.      */
  289.     public function getDepartements(): Collection
  290.     {
  291.         return $this->departements;
  292.     }
  293.     public function addDepartement(Departement $departement): static
  294.     {
  295.         if (!$this->departements->contains($departement)) {
  296.             $this->departements->add($departement);
  297.             $departement->setDirecteur($this);
  298.         }
  299.         return $this;
  300.     }
  301.     public function removeDepartement(Departement $departement): static
  302.     {
  303.         if ($this->departements->removeElement($departement)) {
  304.             // set the owning side to null (unless already changed)
  305.             if ($departement->getDirecteur() === $this) {
  306.                 $departement->setDirecteur(null);
  307.             }
  308.         }
  309.         return $this;
  310.     }
  311.     /**
  312.      * @return Collection<int, AffectationEnseignant>
  313.      */
  314.     public function getAffectationEnseignants(): Collection
  315.     {
  316.         return $this->affectationEnseignants;
  317.     }
  318.     public function addAffectationEnseignant(AffectationEnseignant $affectationEnseignant): static
  319.     {
  320.         if (!$this->affectationEnseignants->contains($affectationEnseignant)) {
  321.             $this->affectationEnseignants->add($affectationEnseignant);
  322.             $affectationEnseignant->setEnseignant($this);
  323.         }
  324.         return $this;
  325.     }
  326.     public function removeAffectationEnseignant(AffectationEnseignant $affectationEnseignant): static
  327.     {
  328.         if ($this->affectationEnseignants->removeElement($affectationEnseignant)) {
  329.             // set the owning side to null (unless already changed)
  330.             if ($affectationEnseignant->getEnseignant() === $this) {
  331.                 $affectationEnseignant->setEnseignant(null);
  332.             }
  333.         }
  334.         return $this;
  335.     }
  336.     public function getBiographie(): ?string
  337.     {
  338.         return $this->biographie;
  339.     }
  340.     public function setBiographie(?string $biographie): static
  341.     {
  342.         $this->biographie $biographie;
  343.         return $this;
  344.     }
  345.     /**
  346.      * @return Collection<int, FeuillePresence>
  347.      */
  348.     public function getFeuillePresences(): Collection
  349.     {
  350.         return $this->feuillePresences;
  351.     }
  352.     public function addFeuillePresence(FeuillePresence $feuillePresence): static
  353.     {
  354.         if (!$this->feuillePresences->contains($feuillePresence)) {
  355.             $this->feuillePresences->add($feuillePresence);
  356.             $feuillePresence->setEnseignant($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeFeuillePresence(FeuillePresence $feuillePresence): static
  361.     {
  362.         if ($this->feuillePresences->removeElement($feuillePresence)) {
  363.             // set the owning side to null (unless already changed)
  364.             if ($feuillePresence->getEnseignant() === $this) {
  365.                 $feuillePresence->setEnseignant(null);
  366.             }
  367.         }
  368.         return $this;
  369.     }
  370.     /**
  371.      * @return Collection<int, PresenceEtudiant>
  372.      */
  373.     public function getPresenceEtudiants(): Collection
  374.     {
  375.         return $this->presenceEtudiants;
  376.     }
  377.     public function addPresenceEtudiant(PresenceEtudiant $presenceEtudiant): static
  378.     {
  379.         if (!$this->presenceEtudiants->contains($presenceEtudiant)) {
  380.             $this->presenceEtudiants->add($presenceEtudiant);
  381.             $presenceEtudiant->setEtudiant($this);
  382.         }
  383.         return $this;
  384.     }
  385.     public function removePresenceEtudiant(PresenceEtudiant $presenceEtudiant): static
  386.     {
  387.         if ($this->presenceEtudiants->removeElement($presenceEtudiant)) {
  388.             // set the owning side to null (unless already changed)
  389.             if ($presenceEtudiant->getEtudiant() === $this) {
  390.                 $presenceEtudiant->setEtudiant(null);
  391.             }
  392.         }
  393.         return $this;
  394.     }
  395. }