src/Entity/User.php line 18

  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. /**
  11.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  12.  */
  13. #[ORM\Entity(repositoryClassUserRepository::class)]
  14. #[ORM\Table(name'`user`')]
  15. class User implements UserInterfacePasswordAuthenticatedUserInterface
  16. {
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column(type'integer')]
  20.     private $id;
  21.     #[ORM\Column(type'string'length180uniquetrue)]
  22.     private $email;
  23.     #[ORM\Column(type'json')]
  24.     private $roles = [];
  25.     #[ORM\Column(type'string')]
  26.     private $password;
  27.     #[ORM\Column(type'string'length255)]
  28.     private $firstName;
  29.     #[ORM\Column(type'string'length255)]
  30.     private $lastName;
  31.     #[ORM\Column(type'datetime_immutable')]
  32.     private $createdAt;
  33.     #[ORM\OneToMany(mappedBy'atUser'targetEntityAdress::class, orphanRemovalfalse)]
  34.     private $adress;
  35.     #[ORM\Column(type'boolean')]
  36.     private $isVerified false;
  37.     #[ORM\OneToMany(mappedBy'userOf'targetEntityOrder::class)]
  38.     private $orders;
  39.     #[ORM\OneToMany(mappedBy'forUser'targetEntityNotifications::class, orphanRemovaltrue)]
  40.     private $notifications;
  41.     #[ORM\Column(type'string'length255nullabletrue)]
  42.     private $stripeUserId;
  43.     #[ORM\Column(type'string'length255nullabletrue)]
  44.     private $societe;
  45.     #[ORM\Column(type'boolean')]
  46.     private $IsBanned;
  47.     #[ORM\OneToMany(mappedBy'userOf'targetEntityHelp::class)]
  48.     private Collection $helps;
  49.     public function __construct()
  50.     {
  51.         $this->createdAt = new \DateTimeImmutable();
  52.         $this->adress = new ArrayCollection();
  53.         $this->orders = new ArrayCollection();
  54.         $this->notifications = new ArrayCollection();
  55.         $this->IsBanned false;
  56.         $this->helps = new ArrayCollection();
  57.     }
  58.     public function __toString()
  59.     {
  60.         return $this->firstName ' ' $this->lastName;
  61.     }
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getEmail(): ?string
  67.     {
  68.         return $this->email;
  69.     }
  70.     public function setEmail(string $email): self
  71.     {
  72.         $this->email $email;
  73.         return $this;
  74.     }
  75.     /**
  76.      * A visual identifier that represents this user.
  77.      *
  78.      * @see UserInterface
  79.      */
  80.     public function getUserIdentifier(): string
  81.     {
  82.         return (string) $this->email;
  83.     }
  84.     /**
  85.      * @see UserInterface
  86.      */
  87.     public function getRoles(): array
  88.     {
  89.         $roles $this->roles;
  90.         // guarantee every user at least has ROLE_USER
  91.         $roles[] = 'ROLE_USER';
  92.         return array_unique($roles);
  93.     }
  94.     public function setRoles(array $roles): self
  95.     {
  96.         $this->roles $roles;
  97.         return $this;
  98.     }
  99.     /**
  100.      * @see PasswordAuthenticatedUserInterface
  101.      */
  102.     public function getPassword(): string
  103.     {
  104.         return $this->password;
  105.     }
  106.     public function setPassword(string $password): self
  107.     {
  108.         $this->password $password;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @see UserInterface
  113.      */
  114.     public function eraseCredentials()
  115.     {
  116.         // If you store any temporary, sensitive data on the user, clear it here
  117.         // $this->plainPassword = null;
  118.     }
  119.     public function getFirstName(): ?string
  120.     {
  121.         return $this->firstName;
  122.     }
  123.     public function setFirstName(string $firstName): self
  124.     {
  125.         $this->firstName $firstName;
  126.         return $this;
  127.     }
  128.     public function getLastName(): ?string
  129.     {
  130.         return $this->lastName;
  131.     }
  132.     public function setLastName(string $lastName): self
  133.     {
  134.         $this->lastName $lastName;
  135.         return $this;
  136.     }
  137.     public function getCreatedAt(): ?\DateTimeImmutable
  138.     {
  139.         return $this->createdAt;
  140.     }
  141.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  142.     {
  143.         $this->createdAt $createdAt;
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return Collection|Adress[]
  148.      */
  149.     public function getAdress(): Collection
  150.     {
  151.         return $this->adress;
  152.     }
  153.     public function addAdress(Adress $adress): self
  154.     {
  155.         if (!$this->adress->contains($adress)) {
  156.             $this->adress[] = $adress;
  157.             $adress->setAtUser($this);
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeAdress(Adress $adress): self
  162.     {
  163.         if ($this->adress->removeElement($adress)) {
  164.             // set the owning side to null (unless already changed)
  165.             if ($adress->getAtUser() === $this) {
  166.                 $adress->setAtUser(null);
  167.             }
  168.         }
  169.         return $this;
  170.     }
  171.     public function isVerified(): bool
  172.     {
  173.         return $this->isVerified;
  174.     }
  175.     public function setIsVerified(bool $isVerified): self
  176.     {
  177.         $this->isVerified $isVerified;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection|Order[]
  182.      */
  183.     public function getOrders(): Collection
  184.     {
  185.         return $this->orders;
  186.     }
  187.     public function addOrder(Order $order): self
  188.     {
  189.         if (!$this->orders->contains($order)) {
  190.             $this->orders[] = $order;
  191.             $order->setUserOf($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeOrder(Order $order): self
  196.     {
  197.         if ($this->orders->removeElement($order)) {
  198.             // set the owning side to null (unless already changed)
  199.             if ($order->getUserOf() === $this) {
  200.                 $order->setUserOf(null);
  201.             }
  202.         }
  203.         return $this;
  204.     }
  205.     /**
  206.      * @return Collection|Notifications[]
  207.      */
  208.     public function getNotifications(): Collection
  209.     {
  210.         return $this->notifications;
  211.     }
  212.     public function addNotification(Notifications $notification): self
  213.     {
  214.         if (!$this->notifications->contains($notification)) {
  215.             $this->notifications[] = $notification;
  216.             $notification->setForUser($this);
  217.         }
  218.         return $this;
  219.     }
  220.     public function removeNotification(Notifications $notification): self
  221.     {
  222.         if ($this->notifications->removeElement($notification)) {
  223.             // set the owning side to null (unless already changed)
  224.             if ($notification->getForUser() === $this) {
  225.                 $notification->setForUser(null);
  226.             }
  227.         }
  228.         return $this;
  229.     }
  230.     public function getStripeUserId(): ?string
  231.     {
  232.         return $this->stripeUserId;
  233.     }
  234.     public function setStripeUserId(?string $stripeUserId): self
  235.     {
  236.         $this->stripeUserId $stripeUserId;
  237.         return $this;
  238.     }
  239.     public function getSociete(): ?string
  240.     {
  241.         return $this->societe;
  242.     }
  243.     public function setSociete(?string $societe): self
  244.     {
  245.         $this->societe $societe;
  246.         return $this;
  247.     }
  248.     public function getIsBanned(): ?bool
  249.     {
  250.         return $this->IsBanned;
  251.     }
  252.     public function setIsBanned(bool $IsBanned): self
  253.     {
  254.         $this->IsBanned $IsBanned;
  255.         return $this;
  256.     }
  257.     /**
  258.      * @return Collection<int, Help>
  259.      */
  260.     public function getHelps(): Collection
  261.     {
  262.         return $this->helps;
  263.     }
  264.     public function addHelp(Help $help): self
  265.     {
  266.         if (!$this->helps->contains($help)) {
  267.             $this->helps->add($help);
  268.             $help->setUserOf($this);
  269.         }
  270.         return $this;
  271.     }
  272.     public function removeHelp(Help $help): self
  273.     {
  274.         if ($this->helps->removeElement($help)) {
  275.             // set the owning side to null (unless already changed)
  276.             if ($help->getUserOf() === $this) {
  277.                 $help->setUserOf(null);
  278.             }
  279.         }
  280.         return $this;
  281.     }
  282. }