src/Entity/User.php line 16

Open in your IDE?
  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\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. #[ORM\Table(name'`user`')]
  12. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length180uniquetrue)]
  20.     private ?string $email null;
  21.     #[ORM\Column]
  22.     private array $roles = [];
  23.     /**
  24.      * @var string The hashed password
  25.      */
  26.     #[ORM\Column]
  27.     private ?string $password null;
  28.     #[ORM\Column(length255)]
  29.     private ?string $nom null;
  30.     #[ORM\Column(length255)]
  31.     private ?string $prenom null;
  32.     #[ORM\Column(length255)]
  33.     private ?string $tel null;
  34.     #[ORM\Column(nullabletrue)]
  35.     private ?bool $status null;
  36.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityContact::class)]
  37.     private Collection $contacts;
  38.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityProject::class)]
  39.     private Collection $projects;
  40.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityDossier::class)]
  41.     private Collection $dossiers;
  42.     #[ORM\OneToMany(mappedBy'userr'targetEntityVariableValue::class)]
  43.     private Collection $variableValues;
  44.     #[ORM\OneToMany(mappedBy'userr'targetEntityVariable::class)]
  45.     private Collection $variables;
  46.     public function __construct()
  47.     {
  48.         $this->contacts = new ArrayCollection();
  49.         $this->projects = new ArrayCollection();
  50.         $this->dossiers = new ArrayCollection();
  51.         $this->variableValues = new ArrayCollection();
  52.         $this->variables = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getEmail(): ?string
  59.     {
  60.         return $this->email;
  61.     }
  62.     public function setEmail(string $email): static
  63.     {
  64.         $this->email $email;
  65.         return $this;
  66.     }
  67.     /**
  68.      * A visual identifier that represents this user.
  69.      *
  70.      * @see UserInterface
  71.      */
  72.     public function getUserIdentifier(): string
  73.     {
  74.         return (string) $this->email;
  75.     }
  76.     /**
  77.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  78.      */
  79.     public function getUsername(): string
  80.     {
  81.         return (string) $this->email;
  82.     }
  83.     /**
  84.      * @see UserInterface
  85.      */
  86.     public function getRoles(): array
  87.     {
  88.         $roles $this->roles;
  89.         // guarantee every user at least has ROLE_USER
  90.         $roles[] = 'ROLE_USER';
  91.         return array_unique($roles);
  92.     }
  93.     public function setRoles(array $roles): static
  94.     {
  95.         $this->roles $roles;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @see PasswordAuthenticatedUserInterface
  100.      */
  101.     public function getPassword(): string
  102.     {
  103.         return $this->password;
  104.     }
  105.     public function setPassword(string $password): static
  106.     {
  107.         $this->password $password;
  108.         return $this;
  109.     }
  110.     /**
  111.      * Returning a salt is only needed, if you are not using a modern
  112.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  113.      *
  114.      * @see UserInterface
  115.      */
  116.     public function getSalt(): ?string
  117.     {
  118.         return null;
  119.     }
  120.     /**
  121.      * @see UserInterface
  122.      */
  123.     public function eraseCredentials(): void
  124.     {
  125.         // If you store any temporary, sensitive data on the user, clear it here
  126.         // $this->plainPassword = null;
  127.     }
  128.     public function getNom(): ?string
  129.     {
  130.         return $this->nom;
  131.     }
  132.     public function setNom(string $nom): static
  133.     {
  134.         $this->nom $nom;
  135.         return $this;
  136.     }
  137.     public function getPrenom(): ?string
  138.     {
  139.         return $this->prenom;
  140.     }
  141.     public function setPrenom(string $prenom): static
  142.     {
  143.         $this->prenom $prenom;
  144.         return $this;
  145.     }
  146.     public function getTel(): ?string
  147.     {
  148.         return $this->tel;
  149.     }
  150.     public function setTel(string $tel): static
  151.     {
  152.         $this->tel $tel;
  153.         return $this;
  154.     }
  155.     public function isStatus(): ?bool
  156.     {
  157.         return $this->status;
  158.     }
  159.     public function setStatus(?bool $status): static
  160.     {
  161.         $this->status $status;
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return Collection<int, Contact>
  166.      */
  167.     public function getContacts(): Collection
  168.     {
  169.         return $this->contacts;
  170.     }
  171.     public function addContact(Contact $contact): static
  172.     {
  173.         if (!$this->contacts->contains($contact)) {
  174.             $this->contacts->add($contact);
  175.             $contact->setUtilisateur($this);
  176.         }
  177.         return $this;
  178.     }
  179.     public function removeContact(Contact $contact): static
  180.     {
  181.         if ($this->contacts->removeElement($contact)) {
  182.             // set the owning side to null (unless already changed)
  183.             if ($contact->getUtilisateur() === $this) {
  184.                 $contact->setUtilisateur(null);
  185.             }
  186.         }
  187.         return $this;
  188.     }
  189.     /**
  190.      * @return Collection<int, Project>
  191.      */
  192.     public function getProjects(): Collection
  193.     {
  194.         return $this->projects;
  195.     }
  196.     public function addProject(Project $project): static
  197.     {
  198.         if (!$this->projects->contains($project)) {
  199.             $this->projects->add($project);
  200.             $project->setUtilisateur($this);
  201.         }
  202.         return $this;
  203.     }
  204.     public function removeProject(Project $project): static
  205.     {
  206.         if ($this->projects->removeElement($project)) {
  207.             // set the owning side to null (unless already changed)
  208.             if ($project->getUtilisateur() === $this) {
  209.                 $project->setUtilisateur(null);
  210.             }
  211.         }
  212.         return $this;
  213.     }
  214.     /**
  215.      * @return Collection<int, Dossier>
  216.      */
  217.     public function getDossiers(): Collection
  218.     {
  219.         return $this->dossiers;
  220.     }
  221.     public function addDossier(Dossier $dossier): static
  222.     {
  223.         if (!$this->dossiers->contains($dossier)) {
  224.             $this->dossiers->add($dossier);
  225.             $dossier->setUtilisateur($this);
  226.         }
  227.         return $this;
  228.     }
  229.     public function removeDossier(Dossier $dossier): static
  230.     {
  231.         if ($this->dossiers->removeElement($dossier)) {
  232.             // set the owning side to null (unless already changed)
  233.             if ($dossier->getUtilisateur() === $this) {
  234.                 $dossier->setUtilisateur(null);
  235.             }
  236.         }
  237.         return $this;
  238.     }
  239.     /**
  240.      * @return Collection<int, VariableValue>
  241.      */
  242.     public function getVariableValues(): Collection
  243.     {
  244.         return $this->variableValues;
  245.     }
  246.     public function addVariableValue(VariableValue $variableValue): static
  247.     {
  248.         if (!$this->variableValues->contains($variableValue)) {
  249.             $this->variableValues->add($variableValue);
  250.             $variableValue->setUserr($this);
  251.         }
  252.         return $this;
  253.     }
  254.     public function removeVariableValue(VariableValue $variableValue): static
  255.     {
  256.         if ($this->variableValues->removeElement($variableValue)) {
  257.             // set the owning side to null (unless already changed)
  258.             if ($variableValue->getUserr() === $this) {
  259.                 $variableValue->setUserr(null);
  260.             }
  261.         }
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return Collection<int, Variable>
  266.      */
  267.     public function getVariables(): Collection
  268.     {
  269.         return $this->variables;
  270.     }
  271.     public function addVariable(Variable $variable): static
  272.     {
  273.         if (!$this->variables->contains($variable)) {
  274.             $this->variables->add($variable);
  275.             $variable->setUserr($this);
  276.         }
  277.         return $this;
  278.     }
  279.     public function removeVariable(Variable $variable): static
  280.     {
  281.         if ($this->variables->removeElement($variable)) {
  282.             // set the owning side to null (unless already changed)
  283.             if ($variable->getUserr() === $this) {
  284.                 $variable->setUserr(null);
  285.             }
  286.         }
  287.         return $this;
  288.     }
  289. }