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.         return $this->classe;
  206.     }
  207.     public function setClasse(?Classe $classe): static
  208.     {
  209.         $this->classe $classe;
  210.         return $this;
  211.     }
  212.     public function getNiveau(): ?Niveau
  213.     {
  214.         return $this->niveau;
  215.     }
  216.     public function setNiveau(?Niveau $niveau): static
  217.     {
  218.         $this->niveau $niveau;
  219.         return $this;
  220.     }
  221.     public function getGrade(): ?Grade
  222.     {
  223.         return $this->grade;
  224.     }
  225.     public function setGrade(?Grade $grade): static
  226.     {
  227.         $this->grade $grade;
  228.         return $this;
  229.     }
  230.     /**
  231.      * @return Collection<int, AffectationEtudiant>
  232.      */
  233.     public function getAffectationEtudiants(): Collection
  234.     {
  235.         return $this->affectationEtudiants;
  236.     }
  237.     public function addAffectationEtudiant(AffectationEtudiant $affectationEtudiant): static
  238.     {
  239.         if (!$this->affectationEtudiants->contains($affectationEtudiant)) {
  240.             $this->affectationEtudiants->add($affectationEtudiant);
  241.             $affectationEtudiant->setEtudiant($this);
  242.         }
  243.         return $this;
  244.     }
  245.     public function removeAffectationEtudiant(AffectationEtudiant $affectationEtudiant): static
  246.     {
  247.         if ($this->affectationEtudiants->removeElement($affectationEtudiant)) {
  248.             // set the owning side to null (unless already changed)
  249.             if ($affectationEtudiant->getEtudiant() === $this) {
  250.                 $affectationEtudiant->setEtudiant(null);
  251.             }
  252.         }
  253.         return $this;
  254.     }
  255.     public function getSituation(): ?string
  256.     {
  257.         return $this->situation;
  258.     }
  259.     public function setSituation(?string $situation): static
  260.     {
  261.         $this->situation $situation;
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return Collection<int, Departement>
  266.      */
  267.     public function getDepartements(): Collection
  268.     {
  269.         return $this->departements;
  270.     }
  271.     public function addDepartement(Departement $departement): static
  272.     {
  273.         if (!$this->departements->contains($departement)) {
  274.             $this->departements->add($departement);
  275.             $departement->setDirecteur($this);
  276.         }
  277.         return $this;
  278.     }
  279.     public function removeDepartement(Departement $departement): static
  280.     {
  281.         if ($this->departements->removeElement($departement)) {
  282.             // set the owning side to null (unless already changed)
  283.             if ($departement->getDirecteur() === $this) {
  284.                 $departement->setDirecteur(null);
  285.             }
  286.         }
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return Collection<int, AffectationEnseignant>
  291.      */
  292.     public function getAffectationEnseignants(): Collection
  293.     {
  294.         return $this->affectationEnseignants;
  295.     }
  296.     public function addAffectationEnseignant(AffectationEnseignant $affectationEnseignant): static
  297.     {
  298.         if (!$this->affectationEnseignants->contains($affectationEnseignant)) {
  299.             $this->affectationEnseignants->add($affectationEnseignant);
  300.             $affectationEnseignant->setEnseignant($this);
  301.         }
  302.         return $this;
  303.     }
  304.     public function removeAffectationEnseignant(AffectationEnseignant $affectationEnseignant): static
  305.     {
  306.         if ($this->affectationEnseignants->removeElement($affectationEnseignant)) {
  307.             // set the owning side to null (unless already changed)
  308.             if ($affectationEnseignant->getEnseignant() === $this) {
  309.                 $affectationEnseignant->setEnseignant(null);
  310.             }
  311.         }
  312.         return $this;
  313.     }
  314.     public function getBiographie(): ?string
  315.     {
  316.         return $this->biographie;
  317.     }
  318.     public function setBiographie(?string $biographie): static
  319.     {
  320.         $this->biographie $biographie;
  321.         return $this;
  322.     }
  323.     /**
  324.      * @return Collection<int, FeuillePresence>
  325.      */
  326.     public function getFeuillePresences(): Collection
  327.     {
  328.         return $this->feuillePresences;
  329.     }
  330.     public function addFeuillePresence(FeuillePresence $feuillePresence): static
  331.     {
  332.         if (!$this->feuillePresences->contains($feuillePresence)) {
  333.             $this->feuillePresences->add($feuillePresence);
  334.             $feuillePresence->setEnseignant($this);
  335.         }
  336.         return $this;
  337.     }
  338.     public function removeFeuillePresence(FeuillePresence $feuillePresence): static
  339.     {
  340.         if ($this->feuillePresences->removeElement($feuillePresence)) {
  341.             // set the owning side to null (unless already changed)
  342.             if ($feuillePresence->getEnseignant() === $this) {
  343.                 $feuillePresence->setEnseignant(null);
  344.             }
  345.         }
  346.         return $this;
  347.     }
  348.     /**
  349.      * @return Collection<int, PresenceEtudiant>
  350.      */
  351.     public function getPresenceEtudiants(): Collection
  352.     {
  353.         return $this->presenceEtudiants;
  354.     }
  355.     public function addPresenceEtudiant(PresenceEtudiant $presenceEtudiant): static
  356.     {
  357.         if (!$this->presenceEtudiants->contains($presenceEtudiant)) {
  358.             $this->presenceEtudiants->add($presenceEtudiant);
  359.             $presenceEtudiant->setEtudiant($this);
  360.         }
  361.         return $this;
  362.     }
  363.     public function removePresenceEtudiant(PresenceEtudiant $presenceEtudiant): static
  364.     {
  365.         if ($this->presenceEtudiants->removeElement($presenceEtudiant)) {
  366.             // set the owning side to null (unless already changed)
  367.             if ($presenceEtudiant->getEtudiant() === $this) {
  368.                 $presenceEtudiant->setEtudiant(null);
  369.             }
  370.         }
  371.         return $this;
  372.     }
  373. }