src/Entity/User.php line 19

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 JsonSerializable;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. /**
  11.  * @ORM\Entity(repositoryClass=UserRepository::class)
  12.  * @ORM\Table(name="`users`")
  13.  * @UniqueEntity(fields={"usermane"}, message="There is already an account with this usermane")
  14.  * @method string getUserIdentifier()
  15.  */
  16. class User implements UserInterfaceJsonSerializable
  17. {
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="string", length=180)
  26.      */
  27.     private $usermane;
  28.     /**
  29.      * @ORM\Column(type="json")
  30.      */
  31.     private $roles = [];
  32.     /**
  33.      * @var string The hashed password
  34.      * @ORM\Column(type="string", nullable=true)
  35.      */
  36.     private $password;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $civility;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      */
  44.     private $firstName;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $LastName;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      */
  52.     private $email;
  53.     /**
  54.      * @ORM\Column(type="text", nullable=true)
  55.      */
  56.     private $description;
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true)
  59.      */
  60.     private $phone;
  61.     /**
  62.      * @ORM\Column(type="string", length=255, nullable=true)
  63.      */
  64.     private $second_phone;
  65.     /**
  66.      * @ORM\Column(type="text", nullable=true)
  67.      */
  68.     private $adress;
  69.     /**
  70.      * @ORM\Column(type="text", nullable=true)
  71.      */
  72.     private $second_adress;
  73.     /**
  74.      * @ORM\Column(type="string", length=255, nullable=true)
  75.      */
  76.     private $country;
  77.     /**
  78.      * @ORM\Column(type="string", length=255, nullable=true)
  79.      */
  80.     private $region;
  81.     /**
  82.      * @ORM\Column(type="string", length=255, nullable=true)
  83.      */
  84.     private $city;
  85.     /**
  86.      * @ORM\Column(type="string", length=255, nullable=true)
  87.      */
  88.     private $tariff_category;
  89.     /**
  90.      * @ORM\Column(type="string", length=255, nullable=true)
  91.      */
  92.     private $zip;
  93.     /**
  94.      * @ORM\Column(type="string", length=255, nullable=true)
  95.      */
  96.     private $type;
  97.     /**
  98.      * @ORM\Column(type="boolean")
  99.      */
  100.     private $isVerified false;
  101.     /**
  102.      * @ORM\OneToMany(targetEntity=Link::class, mappedBy="user",cascade={"persist"})
  103.      */
  104.     private $links;
  105.     /**
  106.      * @ORM\Column(type="datetime")
  107.      */
  108.     private $createdAt;
  109.     /**
  110.      * @ORM\OneToMany(targetEntity=Document::class, mappedBy="client")
  111.      */
  112.     private $documents;
  113.     /**
  114.      * @ORM\OneToMany(targetEntity=Document::class, mappedBy="user")
  115.      */
  116.     private $userDocuments;
  117.     /**
  118.      * @ORM\OneToMany(targetEntity=Address::class, mappedBy="user")
  119.      */
  120.     private $multiAddress;
  121.     /**
  122.      * @ORM\OneToMany(targetEntity=Comment::class, mappedBy="user")
  123.      */
  124.     private $comments;
  125.     /**
  126.      * @ORM\ManyToOne(targetEntity=Supplier::class, inversedBy="contacts")
  127.      */
  128.     private $supplier;
  129.     /**
  130.      * @ORM\ManyToOne(targetEntity=Promotion::class, inversedBy="clients")
  131.      */
  132.     private $promotion;
  133.     /**
  134.      * @ORM\OneToMany(targetEntity=Activity::class, mappedBy="currentUser")
  135.      * @ORM\OrderBy({"ceratedAt" = "DESC"})
  136.      */
  137.     private $activities;
  138.     /**
  139.      * @ORM\ManyToOne(targetEntity=GroupUser::class, inversedBy="users")
  140.      */
  141.     private $groupUser;
  142.     public function __construct()
  143.     {
  144.         $this->links = new ArrayCollection();
  145.         $this->documents = new ArrayCollection();
  146.         $this->userDocuments = new ArrayCollection();
  147.         $this->multiAddress = new ArrayCollection();
  148.         $this->comments = new ArrayCollection();
  149.         $this->activities = new ArrayCollection();
  150.     }
  151.     public function getId(): ?int
  152.     {
  153.         return $this->id;
  154.     }
  155.     public function getUsermane(): ?string
  156.     {
  157.         return $this->usermane;
  158.     }
  159.     public function setUsermane(string $usermane): self
  160.     {
  161.         $this->usermane $usermane;
  162.         return $this;
  163.     }
  164.     /**
  165.      * A visual identifier that represents this user.
  166.      *
  167.      * @see UserInterface
  168.      */
  169.     public function getUsername(): string
  170.     {
  171.         return (string) $this->usermane;
  172.     }
  173.     /**
  174.      * @see UserInterface
  175.      */
  176.     public function getRoles(): array
  177.     {
  178.         $roles $this->roles;
  179.         // guarantee every user at least has ROLE_USER
  180.         $roles[] = 'ROLE_USER';
  181.         return array_unique($roles);
  182.     }
  183.     public function setRoles(array $roles): self
  184.     {
  185.         $this->roles $roles;
  186.         return $this;
  187.     }
  188.     /**
  189.      * @see UserInterface
  190.      */
  191.     public function getPassword(): string
  192.     {
  193.         return (string) $this->password;
  194.     }
  195.     public function setPassword(string $password): self
  196.     {
  197.         $this->password $password;
  198.         return $this;
  199.     }
  200.     /**
  201.      * Returning a salt is only needed, if you are not using a modern
  202.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  203.      *
  204.      * @see UserInterface
  205.      */
  206.     public function getSalt(): ?string
  207.     {
  208.         return null;
  209.     }
  210.     /**
  211.      * @see UserInterface
  212.      */
  213.     public function eraseCredentials()
  214.     {
  215.         // If you store any temporary, sensitive data on the user, clear it here
  216.         // $this->plainPassword = null;
  217.     }
  218.     public function getCivility(): ?string
  219.     {
  220.         return $this->civility;
  221.     }
  222.     public function setCivility(string $civility): self
  223.     {
  224.         $this->civility $civility;
  225.         return $this;
  226.     }
  227.     public function getFirstName(): ?string
  228.     {
  229.         return $this->firstName;
  230.     }
  231.     public function setFirstName(string $firstName): self
  232.     {
  233.         $this->firstName $firstName;
  234.         return $this;
  235.     }
  236.     public function getLastName(): ?string
  237.     {
  238.         return $this->LastName;
  239.     }
  240.     public function setLastName(string $LastName): self
  241.     {
  242.         $this->LastName $LastName;
  243.         return $this;
  244.     }
  245.     public function getEmail(): ?string
  246.     {
  247.         return $this->email;
  248.     }
  249.     public function setEmail(string $email): self
  250.     {
  251.         $this->email $email;
  252.         return $this;
  253.     }
  254.     public function getDescription(): ?string
  255.     {
  256.         return $this->description;
  257.     }
  258.     public function setDescription(string $description): self
  259.     {
  260.         $this->description $description;
  261.         return $this;
  262.     }
  263.     public function getPhone(): ?string
  264.     {
  265.         return $this->phone;
  266.     }
  267.     public function setPhone(string $phone): self
  268.     {
  269.         $this->phone $phone;
  270.         return $this;
  271.     }
  272.     public function getSecondPhone(): ?string
  273.     {
  274.         return $this->second_phone;
  275.     }
  276.     public function setSecondPhone(?string $second_phone): self
  277.     {
  278.         $this->second_phone $second_phone;
  279.         return $this;
  280.     }
  281.     public function getAdress(): ?string
  282.     {
  283.         return $this->adress;
  284.     }
  285.     public function setAdress(string $adress): self
  286.     {
  287.         $this->adress $adress;
  288.         return $this;
  289.     }
  290.     public function getSecondAdress(): ?string
  291.     {
  292.         return $this->second_adress;
  293.     }
  294.     public function setSecondAdress(?string $second_adress): self
  295.     {
  296.         $this->second_adress $second_adress;
  297.         return $this;
  298.     }
  299.     public function getCountry(): ?string
  300.     {
  301.         return $this->country;
  302.     }
  303.     public function setCountry(string $country): self
  304.     {
  305.         $this->country $country;
  306.         return $this;
  307.     }
  308.     public function getRegion(): ?string
  309.     {
  310.         return $this->region;
  311.     }
  312.     public function setRegion(string $region): self
  313.     {
  314.         $this->region $region;
  315.         return $this;
  316.     }
  317.     public function getCity(): ?string
  318.     {
  319.         return $this->city;
  320.     }
  321.     public function setCity(string $city): self
  322.     {
  323.         $this->city $city;
  324.         return $this;
  325.     }
  326.     public function getTariffCategory(): ?string
  327.     {
  328.         return $this->tariff_category;
  329.     }
  330.     public function setTariffCategory(?string $tariff_category): self
  331.     {
  332.         $this->tariff_category $tariff_category;
  333.         return $this;
  334.     }
  335.     public function getZip(): ?string
  336.     {
  337.         return $this->zip;
  338.     }
  339.     public function setZip(string $zip): self
  340.     {
  341.         $this->zip $zip;
  342.         return $this;
  343.     }
  344.     public function getType(): ?string
  345.     {
  346.         return $this->type;
  347.     }
  348.     public function setType(string $type): self
  349.     {
  350.         $this->type $type;
  351.         return $this;
  352.     }
  353.     public function isVerified(): bool
  354.     {
  355.         return $this->isVerified;
  356.     }
  357.     public function setIsVerified(bool $isVerified): self
  358.     {
  359.         $this->isVerified $isVerified;
  360.         return $this;
  361.     }
  362.     /**
  363.      * @return Collection|Link[]
  364.      */
  365.     public function getLinks(): Collection
  366.     {
  367.         return $this->links;
  368.     }
  369.     public function addLink(Link $link): self
  370.     {
  371.         if (!$this->links->contains($link)) {
  372.             $this->links[] = $link;
  373.             $link->setUser($this);
  374.         }
  375.         return $this;
  376.     }
  377.     public function removeLink(Link $link): self
  378.     {
  379.         if ($this->links->removeElement($link)) {
  380.             // set the owning side to null (unless already changed)
  381.             if ($link->getUser() === $this) {
  382.                 $link->setUser(null);
  383.             }
  384.         }
  385.         return $this;
  386.     }
  387.     public function getCreatedAt(): ?\DateTimeInterface
  388.     {
  389.         return $this->createdAt;
  390.     }
  391.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  392.     {
  393.         $this->createdAt $createdAt;
  394.         return $this;
  395.     }
  396.     /**
  397.      * @return Collection|Document[]
  398.      */
  399.     public function getDocuments(): Collection
  400.     {
  401.         return $this->documents;
  402.     }
  403.     public function addDocument(Document $document): self
  404.     {
  405.         if (!$this->documents->contains($document)) {
  406.             $this->documents[] = $document;
  407.             $document->setClient($this);
  408.         }
  409.         return $this;
  410.     }
  411.     public function removeDocument(Document $document): self
  412.     {
  413.         if ($this->documents->removeElement($document)) {
  414.             // set the owning side to null (unless already changed)
  415.             if ($document->getClient() === $this) {
  416.                 $document->setClient(null);
  417.             }
  418.         }
  419.         return $this;
  420.     }
  421.     /**
  422.      * @return Collection|Document[]
  423.      */
  424.     public function getUserDocuments(): Collection
  425.     {
  426.         return $this->userDocuments;
  427.     }
  428.     public function addUserDocument(Document $userDocument): self
  429.     {
  430.         if (!$this->userDocuments->contains($userDocument)) {
  431.             $this->userDocuments[] = $userDocument;
  432.             $userDocument->setUser($this);
  433.         }
  434.         return $this;
  435.     }
  436.     public function removeUserDocument(Document $userDocument): self
  437.     {
  438.         if ($this->userDocuments->removeElement($userDocument)) {
  439.             // set the owning side to null (unless already changed)
  440.             if ($userDocument->getUser() === $this) {
  441.                 $userDocument->setUser(null);
  442.             }
  443.         }
  444.         return $this;
  445.     }
  446.     /**
  447.      * @return Collection|Address[]
  448.      */
  449.     public function getMultiAddress(): Collection
  450.     {
  451.         return $this->multiAddress;
  452.     }
  453.     public function addMultiAddress(Address $multiAddress): self
  454.     {
  455.         if (!$this->multiAddress->contains($multiAddress)) {
  456.             $this->multiAddress[] = $multiAddress;
  457.             $multiAddress->setUser($this);
  458.         }
  459.         return $this;
  460.     }
  461.     public function removeMultiAddress(Address $multiAddress): self
  462.     {
  463.         if ($this->multiAddress->removeElement($multiAddress)) {
  464.             // set the owning side to null (unless already changed)
  465.             if ($multiAddress->getUser() === $this) {
  466.                 $multiAddress->setUser(null);
  467.             }
  468.         }
  469.         return $this;
  470.     }
  471.     /**
  472.      * @return Collection|Comment[]
  473.      */
  474.     public function getComments(): Collection
  475.     {
  476.         return $this->comments;
  477.     }
  478.     public function addComment(Comment $comment): self
  479.     {
  480.         if (!$this->comments->contains($comment)) {
  481.             $this->comments[] = $comment;
  482.             $comment->setUser($this);
  483.         }
  484.         return $this;
  485.     }
  486.     public function removeComment(Comment $comment): self
  487.     {
  488.         if ($this->comments->removeElement($comment)) {
  489.             // set the owning side to null (unless already changed)
  490.             if ($comment->getUser() === $this) {
  491.                 $comment->setUser(null);
  492.             }
  493.         }
  494.         return $this;
  495.     }
  496.     public function getSupplier(): ?Supplier
  497.     {
  498.         return $this->supplier;
  499.     }
  500.     public function setSupplier(?Supplier $supplier): self
  501.     {
  502.         $this->supplier $supplier;
  503.         return $this;
  504.     }
  505.     public function getPromotion(): ?Promotion
  506.     {
  507.         return $this->promotion;
  508.     }
  509.     public function setPromotion(?Promotion $promotion): self
  510.     {
  511.         $this->promotion $promotion;
  512.         return $this;
  513.     }
  514.     /**
  515.      * @return Collection|Activity[]
  516.      */
  517.     public function getActivities(): Collection
  518.     {
  519.         return $this->activities;
  520.     }
  521.     public function addActivity(Activity $activity): self
  522.     {
  523.         if (!$this->activities->contains($activity)) {
  524.             $this->activities[] = $activity;
  525.             $activity->setCurrentUser($this);
  526.         }
  527.         return $this;
  528.     }
  529.     public function removeActivity(Activity $activity): self
  530.     {
  531.         if ($this->activities->removeElement($activity)) {
  532.             // set the owning side to null (unless already changed)
  533.             if ($activity->getCurrentUser() === $this) {
  534.                 $activity->setCurrentUser(null);
  535.             }
  536.         }
  537.         return $this;
  538.     }
  539.     public function getGroupUser(): ?GroupUser
  540.     {
  541.         return $this->groupUser;
  542.     }
  543.     public function setGroupUser(?GroupUser $groupUser): self
  544.     {
  545.         $this->groupUser $groupUser;
  546.         return $this;
  547.     }
  548.     public function __call($name$arguments)
  549.     {
  550.         // TODO: Implement @method string getUserIdentifier()
  551.     }
  552.     public function jsonSerialize()
  553.     {
  554.         return array(
  555.             'adress' => $this->getAdress(),
  556.             'second_adress' => $this->getSecondAdress(),
  557.             'firstName' => $this->getFirstName(),
  558.             'lastName' => $this->getLastName(),
  559.             'username' => $this->getUsermane(),
  560.             'email' => $this->getEmail(),
  561.             'password' => '',
  562.             'newPassword' => '',
  563.             'confirmPassword' => ''
  564.         );
  565.     }
  566. }