src/Entity/Users.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UsersRepository;
  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(repositoryClassUsersRepository::class)]
  11. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  12. class Users implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[ORM\Column(type'string'length180uniquetrue)]
  19.     private $email;
  20.     #[ORM\Column(type'json')]
  21.     private $roles = [];
  22.     #[ORM\Column(type'string')]
  23.     private $password;
  24.     #[ORM\Column(type'boolean')]
  25.     private $is_verified false;
  26.     #[ORM\OneToMany(mappedBy'user'targetEntityQuestionari::class, orphanRemovaltrue)]
  27.     private $questionaris;
  28.     #[ORM\OneToMany(mappedBy'user'targetEntityUsersAmbienti::class, orphanRemovaltrue)]
  29.     private $usersAmbientis;
  30.     #[ORM\Column(nullabletrue)]
  31.     private $corsi_moodle;
  32.     #[ORM\OneToMany(mappedBy'user'targetEntityEstrazioni::class, orphanRemovaltrue)]
  33.     private Collection $estrazionis;
  34.     public function __construct()
  35.     {
  36.         $this->questionaris = new ArrayCollection();
  37.         $this->usersAmbientis = new ArrayCollection();
  38.         $this->estrazionis = new ArrayCollection();
  39.     }
  40.     
  41.     public function __toString()
  42.     {
  43.         return $this->email;
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getEmail(): ?string
  50.     {
  51.         return $this->email;
  52.     }
  53.     public function setEmail(string $email): self
  54.     {
  55.         $this->email $email;
  56.         return $this;
  57.     }
  58.     /**
  59.      * A visual identifier that represents this user.
  60.      *
  61.      * @see UserInterface
  62.      */
  63.     public function getUserIdentifier(): string
  64.     {
  65.         return (string) $this->email;
  66.     }
  67.     /**
  68.      * @see UserInterface
  69.      */
  70.     public function getRoles(): array
  71.     {
  72.         $roles $this->roles;
  73.         // guarantee every user at least has ROLE_USER
  74.         $roles[] = 'ROLE_USER';
  75.         return array_unique($roles);
  76.     }
  77.     public function setRoles(array $roles): self
  78.     {
  79.         $this->roles $roles;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @see PasswordAuthenticatedUserInterface
  84.      */
  85.     public function getPassword(): string
  86.     {
  87.         return $this->password;
  88.     }
  89.     public function setPassword(string $password): self
  90.     {
  91.         $this->password $password;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @see UserInterface
  96.      */
  97.     public function eraseCredentials()
  98.     {
  99.         // If you store any temporary, sensitive data on the user, clear it here
  100.         // $this->plainPassword = null;
  101.     }
  102.     public function isVerified(): bool
  103.     {
  104.         return $this->is_verified;
  105.     }
  106.     public function setIsVerified(bool $isVerified): self
  107.     {
  108.         $this->is_verified $isVerified;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return Collection<int, Questionari>
  113.      */
  114.     public function getQuestionaris(): Collection
  115.     {
  116.         return $this->questionaris;
  117.     }
  118.     public function addQuestionari(Questionari $questionari): self
  119.     {
  120.         if (!$this->questionaris->contains($questionari)) {
  121.             $this->questionaris[] = $questionari;
  122.             $questionari->setUser($this);
  123.         }
  124.         return $this;
  125.     }
  126.     public function removeQuestionari(Questionari $questionari): self
  127.     {
  128.         if ($this->questionaris->removeElement($questionari)) {
  129.             // set the owning side to null (unless already changed)
  130.             if ($questionari->getUser() === $this) {
  131.                 $questionari->setUser(null);
  132.             }
  133.         }
  134.         return $this;
  135.     }
  136.     /**
  137.      * @return Collection<int, UsersAmbienti>
  138.      */
  139.     public function getUsersAmbientis(): Collection
  140.     {
  141.         return $this->usersAmbientis;
  142.     }
  143.     public function addUsersAmbienti(UsersAmbienti $usersAmbienti): self
  144.     {
  145.         if (!$this->usersAmbientis->contains($usersAmbienti)) {
  146.             $this->usersAmbientis[] = $usersAmbienti;
  147.             $usersAmbienti->setUser($this);
  148.         }
  149.         return $this;
  150.     }
  151.     public function removeUsersAmbienti(UsersAmbienti $usersAmbienti): self
  152.     {
  153.         if ($this->usersAmbientis->removeElement($usersAmbienti)) {
  154.             // set the owning side to null (unless already changed)
  155.             if ($usersAmbienti->getUser() === $this) {
  156.                 $usersAmbienti->setUser(null);
  157.             }
  158.         }
  159.         return $this;
  160.     }
  161.     public function getCorsiMoodle(): ?string
  162.     {
  163.         return $this->corsi_moodle;
  164.     }
  165.     public function setCorsiMoodle(string $corsi_moodle): self
  166.     {
  167.         $this->corsi_moodle $corsi_moodle;
  168.         return $this;
  169.     }
  170.     /**
  171.      * @return Collection<int, Estrazioni>
  172.      */
  173.     public function getEstrazionis(): Collection
  174.     {
  175.         return $this->estrazionis;
  176.     }
  177.     public function addEstrazioni(Estrazioni $estrazioni): static
  178.     {
  179.         if (!$this->estrazionis->contains($estrazioni)) {
  180.             $this->estrazionis->add($estrazioni);
  181.             $estrazioni->setUser($this);
  182.         }
  183.         return $this;
  184.     }
  185.     public function removeEstrazioni(Estrazioni $estrazioni): static
  186.     {
  187.         if ($this->estrazionis->removeElement($estrazioni)) {
  188.             // set the owning side to null (unless already changed)
  189.             if ($estrazioni->getUser() === $this) {
  190.                 $estrazioni->setUser(null);
  191.             }
  192.         }
  193.         return $this;
  194.     }
  195. }