src/Entity/User.php line 17

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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. #[ORM\Entity(repositoryClass: UserRepository::class)]
  12. #[ORM\Table(name: '`user`')]
  13. #[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
  14. class User implements UserInterface, PasswordAuthenticatedUserInterface
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id = null;
  20.     #[ORM\Column(length: 180, unique: true)]
  21.     private ?string $email = null;
  22.     #[ORM\Column]
  23.     private array $roles = [];
  24.     /**
  25.      * @var string The hashed password
  26.      */
  27.     #[ORM\Column]
  28.     private ?string $password = null;
  29.     #[ORM\Column(length: 150)]
  30.     private ?string $firstnameUser = null;
  31.     #[ORM\Column(length: 150)]
  32.     private ?string $lastnameUser = null;
  33.     #[ORM\Column(length: 20)]
  34.     private ?string $phoneUser = null;
  35.     #[ORM\Column(type: Types::TEXT)]
  36.     private ?string $addressUser = null;
  37.     #[ORM\Column(type: Types::DATE_MUTABLE)]
  38.     private ?\DateTimeInterface $birthdateUser = null;
  39.     #[ORM\ManyToOne(inversedBy: 'users')]
  40.     private ?Sub $sub = null;
  41.     #[ORM\OneToMany(mappedBy: 'user', targetEntity: Devis::class)]
  42.     private Collection $devis;
  43.     #[ORM\OneToMany(mappedBy: 'user', targetEntity: Contact::class)]
  44.     private Collection $contacts;
  45.     #[ORM\ManyToMany(targetEntity: Video::class, inversedBy: 'users')]
  46.     private Collection $video;
  47.     #[ORM\ManyToMany(targetEntity: Program::class, inversedBy: 'users')]
  48.     private Collection $program;
  49.     #[ORM\Column(type: 'boolean')]
  50.     private $isVerified = false;
  51.     #[ORM\Column(type: 'boolean')]
  52.     private $adminn = false;
  53.     public function __construct()
  54.     {
  55.         $this->devis = new ArrayCollection();
  56.         $this->contacts = new ArrayCollection();
  57.         $this->video = new ArrayCollection();
  58.         $this->program = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getEmail(): ?string
  65.     {
  66.         return $this->email;
  67.     }
  68.     public function setEmail(string $email): self
  69.     {
  70.         $this->email = $email;
  71.         return $this;
  72.     }
  73.     /**
  74.      * A visual identifier that represents this user.
  75.      *
  76.      * @see UserInterface
  77.      */
  78.     public function getUserIdentifier(): string
  79.     {
  80.         return (string) $this->email;
  81.     }
  82.     /**
  83.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  84.      */
  85.     public function getUsername(): string
  86.     {
  87.         return (string) $this->email;
  88.     }
  89.     /**
  90.      * @see UserInterface
  91.      */
  92.     public function getRoles(): array
  93.     {
  94.         $roles = $this->roles;
  95.         // guarantee every user at least has ROLE_USER
  96.         $roles[] = 'ROLE_USER';
  97.         return array_unique($roles);
  98.     }
  99.     public function setRoles(array $roles): self
  100.     {
  101.         $this->roles = $roles;
  102.         return $this;
  103.     }
  104.     /**
  105.      * @see PasswordAuthenticatedUserInterface
  106.      */
  107.     public function getPassword(): string
  108.     {
  109.         return $this->password;
  110.     }
  111.     public function setPassword(string $password): self
  112.     {
  113.         $this->password = $password;
  114.         return $this;
  115.     }
  116.     /**
  117.      * Returning a salt is only needed, if you are not using a modern
  118.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  119.      *
  120.      * @see UserInterface
  121.      */
  122.     public function getSalt(): ?string
  123.     {
  124.         return null;
  125.     }
  126.     /**
  127.      * @see UserInterface
  128.      */
  129.     public function eraseCredentials()
  130.     {
  131.         // If you store any temporary, sensitive data on the user, clear it here
  132.         // $this->plainPassword = null;
  133.     }
  134.     public function getFirstnameUser(): ?string
  135.     {
  136.         return $this->firstnameUser;
  137.     }
  138.     public function setFirstnameUser(string $firstnameUser): self
  139.     {
  140.         $this->firstnameUser = $firstnameUser;
  141.         return $this;
  142.     }
  143.     public function getLastnameUser(): ?string
  144.     {
  145.         return $this->lastnameUser;
  146.     }
  147.     public function setLastnameUser(string $lastnameUser): self
  148.     {
  149.         $this->lastnameUser = $lastnameUser;
  150.         return $this;
  151.     }
  152.     public function getPhoneUser(): ?string
  153.     {
  154.         return $this->phoneUser;
  155.     }
  156.     public function setPhoneUser(string $phoneUser): self
  157.     {
  158.         $this->phoneUser = $phoneUser;
  159.         return $this;
  160.     }
  161.     public function getAddressUser(): ?string
  162.     {
  163.         return $this->addressUser;
  164.     }
  165.     public function setAddressUser(string $addressUser): self
  166.     {
  167.         $this->addressUser = $addressUser;
  168.         return $this;
  169.     }
  170.     public function getBirthdateUser(): ?\DateTimeInterface
  171.     {
  172.         return $this->birthdateUser;
  173.     }
  174.     public function setBirthdateUser(\DateTimeInterface $birthdateUser): self
  175.     {
  176.         $this->birthdateUser = $birthdateUser;
  177.         return $this;
  178.     }
  179.     public function getSub(): ?Sub
  180.     {
  181.         return $this->sub;
  182.     }
  183.     public function setSub(?Sub $sub): self
  184.     {
  185.         $this->sub = $sub;
  186.         return $this;
  187.     }
  188.     /**
  189.      * @return Collection<int, Devis>
  190.      */
  191.     public function getDevis(): Collection
  192.     {
  193.         return $this->devis;
  194.     }
  195.     public function addDevi(Devis $devi): self
  196.     {
  197.         if (!$this->devis->contains($devi)) {
  198.             $this->devis->add($devi);
  199.             $devi->setUser($this);
  200.         }
  201.         return $this;
  202.     }
  203.     public function removeDevi(Devis $devi): self
  204.     {
  205.         if ($this->devis->removeElement($devi)) {
  206.             // set the owning side to null (unless already changed)
  207.             if ($devi->getUser() === $this) {
  208.                 $devi->setUser(null);
  209.             }
  210.         }
  211.         return $this;
  212.     }
  213.     /**
  214.      * @return Collection<int, Contact>
  215.      */
  216.     public function getContacts(): Collection
  217.     {
  218.         return $this->contacts;
  219.     }
  220.     public function addContact(Contact $contact): self
  221.     {
  222.         if (!$this->contacts->contains($contact)) {
  223.             $this->contacts->add($contact);
  224.             $contact->setUser($this);
  225.         }
  226.         return $this;
  227.     }
  228.     public function removeContact(Contact $contact): self
  229.     {
  230.         if ($this->contacts->removeElement($contact)) {
  231.             // set the owning side to null (unless already changed)
  232.             if ($contact->getUser() === $this) {
  233.                 $contact->setUser(null);
  234.             }
  235.         }
  236.         return $this;
  237.     }
  238.     /**
  239.      * @return Collection<int, Video>
  240.      */
  241.     public function getVideo(): Collection
  242.     {
  243.         return $this->video;
  244.     }
  245.     public function addVideo(Video $video): self
  246.     {
  247.         if (!$this->video->contains($video)) {
  248.             $this->video->add($video);
  249.         }
  250.         return $this;
  251.     }
  252.     public function removeVideo(Video $video): self
  253.     {
  254.         $this->video->removeElement($video);
  255.         return $this;
  256.     }
  257.     /**
  258.      * @return Collection<int, Program>
  259.      */
  260.     public function getProgram(): Collection
  261.     {
  262.         return $this->program;
  263.     }
  264.     public function addProgram(Program $program): self
  265.     {
  266.         if (!$this->program->contains($program)) {
  267.             $this->program->add($program);
  268.         }
  269.         return $this;
  270.     }
  271.     public function removeProgram(Program $program): self
  272.     {
  273.         $this->program->removeElement($program);
  274.         return $this;
  275.     }
  276.     public function isVerified(): bool
  277.     {
  278.         return $this->isVerified;
  279.     }
  280.     public function setIsVerified(bool $isVerified): self
  281.     {
  282.         $this->isVerified = $isVerified;
  283.         return $this;
  284.     }
  285.     public function isAdminn(): ?bool
  286.     {
  287.         return $this->adminn;
  288.     }
  289.     public function setAdminn(bool $adminn): self
  290.     {
  291.         $this->adminn = $adminn;
  292.         return $this;
  293.     }
  294. }