src/Entity/User.php line 15

  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. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  12. class User implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length180uniquetrue)]
  19.     private ?string $email null;
  20.     #[ORM\Column(length180)]
  21.     public ?string $name null;
  22.     #[ORM\OneToMany(mappedBy'user'targetEntityGallery::class, cascade: ["persist""remove"])]
  23.     protected ?Collection $gallery null;
  24.     #[ORM\OneToMany(mappedBy'user'targetEntityUserGallery::class, cascade: ["persist""remove"])]
  25.     protected ?Collection $userGallery null;
  26.     #[ORM\OneToMany(mappedBy'user'targetEntityUserTemplate::class, cascade: ["persist""remove"])]
  27.     protected ?Collection $userTemplate null;
  28.     #[ORM\OneToMany(mappedBy'manager'targetEntityFinancialPart::class, cascade: ["persist""remove"])]
  29.     protected ?Collection $financialManager null;
  30.     #[ORM\OneToMany(mappedBy'photo1'targetEntityFinancialPart::class, cascade: ["persist""remove"])]
  31.     protected ?Collection $financialPhoto1 null;
  32.     #[ORM\OneToMany(mappedBy'photo2'targetEntityFinancialPart::class, cascade: ["persist""remove"])]
  33.     protected ?Collection $financialPhoto2 null;
  34.     #[ORM\OneToMany(mappedBy'photo3'targetEntityFinancialPart::class, cascade: ["persist""remove"])]
  35.     protected ?Collection $financialPhoto3 null;
  36.     #[ORM\Column]
  37.     private array $roles = [];
  38.     /**
  39.      * @var ?string The hashed password
  40.      */
  41.     #[ORM\Column]
  42.     private ?string $password '';
  43.     #[ORM\Column(type'boolean')]
  44.     private bool $isVerified false;
  45.     public function __toString(): string
  46.     {
  47.         if ($this->name){
  48.             return $this->name;
  49.         }else{
  50.             return '';
  51.         }
  52.     }
  53.     public function __construct()
  54.     {
  55.         $this->gallery = new ArrayCollection();
  56.         $this->userGallery = new ArrayCollection();
  57.         $this->userTemplate = new ArrayCollection();
  58.         $this->financialManager = new ArrayCollection();
  59.         $this->financialPhoto1 = new ArrayCollection();
  60.         $this->financialPhoto2 = new ArrayCollection();
  61.         $this->financialPhoto3 = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getEmail(): ?string
  68.     {
  69.         return $this->email;
  70.     }
  71.     public function setEmail(string $email): self
  72.     {
  73.         $this->email $email;
  74.         return $this;
  75.     }
  76.     /**
  77.      * A visual identifier that represents this user.
  78.      *
  79.      * @see UserInterface
  80.      */
  81.     public function getUserIdentifier(): string
  82.     {
  83.         return (string) $this->email;
  84.     }
  85.     /**
  86.      * @see UserInterface
  87.      */
  88.     public function getRoles(): array
  89.     {
  90.         $roles $this->roles;
  91.         // guarantee every user at least has ROLE_USER
  92.         $roles[] = 'ROLE_USER';
  93.         return array_unique($roles);
  94.     }
  95.     public function setRoles(array $roles): self
  96.     {
  97.         $this->roles $roles;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @see PasswordAuthenticatedUserInterface
  102.      */
  103.     public function getPassword(): ?string
  104.     {
  105.         return $this->password;
  106.     }
  107.     public function setPassword(?string $password): self
  108.     {
  109.         $this->password $password;
  110.         return $this;
  111.     }
  112.     /**
  113.      * @see UserInterface
  114.      */
  115.     public function eraseCredentials()
  116.     {
  117.         // If you store any temporary, sensitive data on the user, clear it here
  118.         // $this->plainPassword = null;
  119.     }
  120.     public function isVerified(): bool
  121.     {
  122.         return $this->isVerified;
  123.     }
  124.     public function setIsVerified(bool $isVerified): self
  125.     {
  126.         $this->isVerified $isVerified;
  127.         return $this;
  128.     }
  129.     public function isIsVerified(): ?bool
  130.     {
  131.         return $this->isVerified;
  132.     }
  133.     /**
  134.      * @return string|null
  135.      */
  136.     public function getName(): ?string
  137.     {
  138.         return $this->name;
  139.     }
  140.     /**
  141.      * @param string|null $name
  142.      */
  143.     public function setName(?string $name): void
  144.     {
  145.         $this->name $name;
  146.     }
  147.     /**
  148.      * @return Collection<int, Gallery>
  149.      */
  150.     public function getGallery(): Collection
  151.     {
  152.         return $this->gallery;
  153.     }
  154.     public function addGallery(Gallery $gallery): static
  155.     {
  156.         if (!$this->gallery->contains($gallery)) {
  157.             $this->gallery->add($gallery);
  158.             $gallery->setUser($this);
  159.         }
  160.         return $this;
  161.     }
  162.     public function removeGallery(Gallery $gallery): static
  163.     {
  164.         if ($this->gallery->removeElement($gallery)) {
  165.             // set the owning side to null (unless already changed)
  166.             if ($gallery->getUser() === $this) {
  167.                 $gallery->setUser(null);
  168.             }
  169.         }
  170.         return $this;
  171.     }
  172.     /**
  173.      * @return Collection<int, UserGallery>
  174.      */
  175.     public function getUserGallery(): Collection
  176.     {
  177.         return $this->userGallery;
  178.     }
  179.     public function addUserGallery(UserGallery $userGallery): static
  180.     {
  181.         if (!$this->userGallery->contains($userGallery)) {
  182.             $this->userGallery->add($userGallery);
  183.             $userGallery->setUser($this);
  184.         }
  185.         return $this;
  186.     }
  187.     public function removeUserGallery(UserGallery $userGallery): static
  188.     {
  189.         if ($this->userGallery->removeElement($userGallery)) {
  190.             // set the owning side to null (unless already changed)
  191.             if ($userGallery->getUser() === $this) {
  192.                 $userGallery->setUser(null);
  193.             }
  194.         }
  195.         return $this;
  196.     }
  197.     /**
  198.      * @return Collection<int, UserTemplate>
  199.      */
  200.     public function getUserTemplate(): Collection
  201.     {
  202.         return $this->userTemplate;
  203.     }
  204.     public function addUserTemplate(UserTemplate $userTemplate): static
  205.     {
  206.         if (!$this->userTemplate->contains($userTemplate)) {
  207.             $this->userTemplate->add($userTemplate);
  208.             $userTemplate->setUser($this);
  209.         }
  210.         return $this;
  211.     }
  212.     public function removeUserTemplate(UserTemplate $userTemplate): static
  213.     {
  214.         if ($this->userTemplate->removeElement($userTemplate)) {
  215.             // set the owning side to null (unless already changed)
  216.             if ($userTemplate->getUser() === $this) {
  217.                 $userTemplate->setUser(null);
  218.             }
  219.         }
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection<int, FinancialPart>
  224.      */
  225.     public function getFinancialManager(): Collection
  226.     {
  227.         return $this->financialManager;
  228.     }
  229.     public function addFinancialManager(FinancialPart $financialManager): static
  230.     {
  231.         if (!$this->financialManager->contains($financialManager)) {
  232.             $this->financialManager->add($financialManager);
  233.             $financialManager->setManager($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeFinancialManager(FinancialPart $financialManager): static
  238.     {
  239.         if ($this->financialManager->removeElement($financialManager)) {
  240.             // set the owning side to null (unless already changed)
  241.             if ($financialManager->getManager() === $this) {
  242.                 $financialManager->setManager(null);
  243.             }
  244.         }
  245.         return $this;
  246.     }
  247.     /**
  248.      * @return Collection<int, FinancialPart>
  249.      */
  250.     public function getFinancialPhoto1(): Collection
  251.     {
  252.         return $this->financialPhoto1;
  253.     }
  254.     public function addFinancialPhoto1(FinancialPart $financialPhoto1): static
  255.     {
  256.         if (!$this->financialPhoto1->contains($financialPhoto1)) {
  257.             $this->financialPhoto1->add($financialPhoto1);
  258.             $financialPhoto1->setPhoto1($this);
  259.         }
  260.         return $this;
  261.     }
  262.     public function removeFinancialPhoto1(FinancialPart $financialPhoto1): static
  263.     {
  264.         if ($this->financialPhoto1->removeElement($financialPhoto1)) {
  265.             // set the owning side to null (unless already changed)
  266.             if ($financialPhoto1->getPhoto1() === $this) {
  267.                 $financialPhoto1->setPhoto1(null);
  268.             }
  269.         }
  270.         return $this;
  271.     }
  272.     /**
  273.      * @return Collection<int, FinancialPart>
  274.      */
  275.     public function getFinancialPhoto2(): Collection
  276.     {
  277.         return $this->financialPhoto2;
  278.     }
  279.     public function addFinancialPhoto2(FinancialPart $financialPhoto2): static
  280.     {
  281.         if (!$this->financialPhoto2->contains($financialPhoto2)) {
  282.             $this->financialPhoto2->add($financialPhoto2);
  283.             $financialPhoto2->setPhoto2($this);
  284.         }
  285.         return $this;
  286.     }
  287.     public function removeFinancialPhoto2(FinancialPart $financialPhoto2): static
  288.     {
  289.         if ($this->financialPhoto2->removeElement($financialPhoto2)) {
  290.             // set the owning side to null (unless already changed)
  291.             if ($financialPhoto2->getPhoto2() === $this) {
  292.                 $financialPhoto2->setPhoto2(null);
  293.             }
  294.         }
  295.         return $this;
  296.     }
  297.     /**
  298.      * @return Collection<int, FinancialPart>
  299.      */
  300.     public function getFinancialPhoto3(): Collection
  301.     {
  302.         return $this->financialPhoto3;
  303.     }
  304.     public function addFinancialPhoto3(FinancialPart $financialPhoto3): static
  305.     {
  306.         if (!$this->financialPhoto3->contains($financialPhoto3)) {
  307.             $this->financialPhoto3->add($financialPhoto3);
  308.             $financialPhoto3->setPhoto3($this);
  309.         }
  310.         return $this;
  311.     }
  312.     public function removeFinancialPhoto3(FinancialPart $financialPhoto3): static
  313.     {
  314.         if ($this->financialPhoto3->removeElement($financialPhoto3)) {
  315.             // set the owning side to null (unless already changed)
  316.             if ($financialPhoto3->getPhoto3() === $this) {
  317.                 $financialPhoto3->setPhoto3(null);
  318.             }
  319.         }
  320.         return $this;
  321.     }
  322. }