src/Entity/User.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\HttpFoundation\File\UploadedFile;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  13.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  14.  */
  15. class User implements UserInterfacePasswordAuthenticatedUserInterface
  16. {
  17.     /**
  18.      * @ORM\Id()
  19.      * @ORM\GeneratedValue()
  20.      * @ORM\Column(type="integer")
  21.      * @Groups("user")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="string", length=180, unique=true)
  26.      * @Groups("user")
  27.      */
  28.     private $username;
  29.     
  30.     /**
  31.      * @ORM\Column(type="string", length=180, unique=true)
  32.      * @Groups("user")
  33.      */
  34.     private $email;
  35.     
  36.     /**
  37.      * @var string The hashed password
  38.      * @ORM\Column(type="string")
  39.      * @Groups("user")
  40.      */
  41.     private $password;
  42.     
  43.     /**
  44.      * @ORM\Column(type="json")
  45.      * @Groups("user")
  46.      */
  47.     private $roles = [];
  48.     /**
  49.      * @ORM\Column(type="string", length=255)
  50.      * @Groups("user")
  51.      */
  52.     private $name;
  53.     /**
  54.      * @ORM\Column(type="string", length=255)
  55.      * @Groups("user")
  56.      */
  57.     private $firstname;
  58.     /**
  59.      * @ORM\Column(type="date")
  60.      */
  61.     private $birthday;
  62.     /**
  63.      * @ORM\Column(type="text")
  64.      */
  65.     private $adress;
  66.     /**
  67.      * @ORM\Column(type="integer")
  68.      */
  69.     private $postalCode;
  70.     /**
  71.      * @ORM\Column(type="string", length=255)
  72.      */
  73.     private $city;
  74.     /**
  75.      * @ORM\Column(type="string", length=255)
  76.      */
  77.     private $country;
  78.     /**
  79.      * @ORM\Column(type="string", length=255)
  80.      */
  81.     private $phone;
  82.     
  83.     
  84.     /**
  85.      * @ORM\Column(type="string", length=255)
  86.      * @Groups("user")
  87.      */
  88.     private $pseudonym;
  89.     
  90.     /**
  91.      * @ORM\ManyToOne(targetEntity="App\Entity\StatutUser", inversedBy="users")
  92.      */
  93.     private $statut;
  94.     /**
  95.      * @ORM\OneToOne(targetEntity="App\Entity\CompagnyInfo", cascade={"persist", "remove"})
  96.      */
  97.     private $compagny;
  98.     /**
  99.      * @ORM\OneToOne(targetEntity="App\Entity\BankInfo", cascade={"persist", "remove"})
  100.      */
  101.     private $bank;
  102.     /**
  103.      * @ORM\OneToOne(targetEntity="App\Entity\ProfilPicture", cascade={"persist", "remove"})
  104.      */
  105.     private $profilPicture;
  106.     /**
  107.      * @ORM\OneToOne(targetEntity="App\Entity\Notation", cascade={"persist", "remove"})
  108.      */
  109.     private $notation;
  110.     /**
  111.      * @ORM\OneToOne(targetEntity="App\Entity\Statistic", cascade={"persist", "remove"})
  112.      */
  113.     private $statistic;
  114.     /**
  115.      * @ORM\OneToMany(targetEntity="App\Entity\GalleryPhoto", mappedBy="userProperty")
  116.      */
  117.     private $galleryPhotos;
  118.     /**
  119.      * @ORM\OneToMany(targetEntity="App\Entity\GalleryVideo", mappedBy="userProperty")
  120.      */
  121.     private $galleryVideos;
  122.     /**
  123.      * @ORM\OneToMany(targetEntity=CommunityPosts::class, mappedBy="userId")
  124.      */
  125.     private $communityPosts;
  126.     /**
  127.      * @ORM\OneToMany(targetEntity=ShoppingCart::class, mappedBy="idUser")
  128.      */
  129.     private $shoppingCarts;
  130.     /**
  131.      * @ORM\OneToMany(targetEntity=Billing::class, mappedBy="idClient")
  132.      */
  133.     private $billings;
  134.     /**
  135.      * @ORM\Column(type="date", nullable=true)
  136.      */
  137.     private $registrationDate;
  138.     /**
  139.      * @ORM\OneToMany(targetEntity=Refund::class, mappedBy="client")
  140.      */
  141.     private $refunds;
  142.     public function __construct()
  143.     {
  144.         $this->galleryPhotos = new ArrayCollection();
  145.         $this->galleryVideos = new ArrayCollection();
  146.         $this->communityPosts = new ArrayCollection();
  147.         $this->shoppingCarts = new ArrayCollection();
  148.         $this->billings = new ArrayCollection();
  149.         $this->refunds = new ArrayCollection();
  150.     }
  151.     
  152.     
  153.     
  154.     /**
  155.      * @param mixed $username
  156.      */
  157.     public function setUsername($username)
  158.     {
  159.         $this->username $username;
  160.         return $this;
  161.     }
  162.     public function getId(): ?int
  163.     {
  164.         return $this->id;
  165.     }
  166.     public function getEmail(): ?string
  167.     {
  168.         return $this->email;
  169.     }
  170.     public function setEmail(string $email): self
  171.     {
  172.         $this->email $email;
  173.         return $this;
  174.     }
  175.     /**
  176.      * A visual identifier that represents this user.
  177.      *
  178.      * @see UserInterface
  179.      */
  180.     public function getUsername(): string
  181.     {
  182.         return (string) $this->email;
  183.     }
  184.     /**
  185.      * @see UserInterface
  186.      */
  187.     public function getRoles(): array
  188.     {
  189.         $roles $this->roles;
  190.         // guarantee every user at least has ROLE_USER
  191.         $roles[] = 'ROLE_USER';
  192.         return array_unique($roles);
  193.     }
  194.     public function setRoles(array $roles): self
  195.     {
  196.         $this->roles $roles;
  197.         return $this;
  198.     }
  199.     /**
  200.      * @see PasswordAuthenticatedUserInterface
  201.      */
  202.     public function getPassword(): string
  203.     {
  204.         return (string) $this->password;
  205.     }
  206.     public function setPassword(string $password): self
  207.     {
  208.         $this->password $password;
  209.         return $this;
  210.     }
  211.     /**
  212.      * @see UserInterface
  213.      */
  214.     public function getSalt()
  215.     {
  216.         // not needed when using the "bcrypt" algorithm in security.yaml
  217.     }
  218.     /**
  219.      * @see UserInterface
  220.      */
  221.     public function eraseCredentials()
  222.     {
  223.         // If you store any temporary, sensitive data on the user, clear it here
  224.         // $this->plainPassword = null;
  225.     }
  226.     public function getName(): ?string
  227.     {
  228.         return $this->name;
  229.     }
  230.     public function setName(string $name): self
  231.     {
  232.         $this->name $name;
  233.         return $this;
  234.     }
  235.     public function getFirstname(): ?string
  236.     {
  237.         return $this->firstname;
  238.     }
  239.     public function setFirstname(string $firstname): self
  240.     {
  241.         $this->firstname $firstname;
  242.         return $this;
  243.     }
  244.     public function getBirthday(): ?\DateTimeInterface
  245.     {
  246.         return $this->birthday;
  247.     }
  248.     public function setBirthday(\DateTimeInterface $birthday): self
  249.     {
  250.         $this->birthday $birthday;
  251.         return $this;
  252.     }
  253.     public function getAdress(): ?string
  254.     {
  255.         return $this->adress;
  256.     }
  257.     public function setAdress(string $adress): self
  258.     {
  259.         $this->adress $adress;
  260.         return $this;
  261.     }
  262.     public function getPostalCode(): ?int
  263.     {
  264.         return $this->postalCode;
  265.     }
  266.     public function setPostalCode(int $postalCode): self
  267.     {
  268.         $this->postalCode $postalCode;
  269.         return $this;
  270.     }
  271.     public function getCity(): ?string
  272.     {
  273.         return $this->city;
  274.     }
  275.     public function setCity(string $city): self
  276.     {
  277.         $this->city $city;
  278.         return $this;
  279.     }
  280.     public function getCountry(): ?string
  281.     {
  282.         return $this->country;
  283.     }
  284.     public function setCountry(string $country): self
  285.     {
  286.         $this->country $country;
  287.         return $this;
  288.     }
  289.     public function getPhone(): ?string
  290.     {
  291.         return $this->phone;
  292.     }
  293.     public function setPhone(string $phone): self
  294.     {
  295.         $this->phone $phone;
  296.         return $this;
  297.     }
  298.     
  299.     
  300.     public function getPseudonym(): ?string
  301.     {
  302.         return $this->pseudonym;
  303.     }
  304.     public function setPseudonym(string $pseudonym): self
  305.     {
  306.         $this->pseudonym $pseudonym;
  307.         return $this;
  308.     }
  309.     
  310.     public function getStatut(): ?StatutUser
  311.     {
  312.         return $this->statut;
  313.     }
  314.     public function setStatut(?StatutUser $statut): self
  315.     {
  316.         $this->statut $statut;
  317.         return $this;
  318.     }
  319.     public function getCompagny(): ?CompagnyInfo
  320.     {
  321.         return $this->compagny;
  322.     }
  323.     public function setCompagny(?CompagnyInfo $compagny): self
  324.     {
  325.         $this->compagny $compagny;
  326.         return $this;
  327.     }
  328.     public function getBank(): ?BankInfo
  329.     {
  330.         return $this->bank;
  331.     }
  332.     public function setBank(?BankInfo $bank): self
  333.     {
  334.         $this->bank $bank;
  335.         return $this;
  336.     }
  337.     public function getProfilPicture(): ?ProfilPicture
  338.     {
  339.         return $this->profilPicture;
  340.     }
  341.     public function setProfilPicture(?ProfilPicture $profilPicture): self
  342.     {
  343.         $this->profilPicture $profilPicture;
  344.         return $this;
  345.     }
  346.     public function getNotation(): ?Notation
  347.     {
  348.         return $this->notation;
  349.     }
  350.     public function setNotation(?Notation $notation): self
  351.     {
  352.         $this->notation $notation;
  353.         return $this;
  354.     }
  355.     public function getStatistic(): ?Statistic
  356.     {
  357.         return $this->statistic;
  358.     }
  359.     public function setStatistic(?Statistic $statistic): self
  360.     {
  361.         $this->statistic $statistic;
  362.         return $this;
  363.     }
  364.     /**
  365.      * @return Collection|GalleryPhoto[]
  366.      */
  367.     public function getGalleryPhotos(): Collection
  368.     {
  369.         return $this->galleryPhotos;
  370.     }
  371.     public function addGalleryPhoto(GalleryPhoto $galleryPhoto): self
  372.     {
  373.         if (!$this->galleryPhotos->contains($galleryPhoto)) {
  374.             $this->galleryPhotos[] = $galleryPhoto;
  375.             $galleryPhoto->setUserProperty($this);
  376.         }
  377.         return $this;
  378.     }
  379.     public function removeGalleryPhoto(GalleryPhoto $galleryPhoto): self
  380.     {
  381.         if ($this->galleryPhotos->contains($galleryPhoto)) {
  382.             $this->galleryPhotos->removeElement($galleryPhoto);
  383.             // set the owning side to null (unless already changed)
  384.             if ($galleryPhoto->getUserProperty() === $this) {
  385.                 $galleryPhoto->setUserProperty(null);
  386.             }
  387.         }
  388.         return $this;
  389.     }
  390.     /**
  391.      * @return Collection|GalleryVideo[]
  392.      */
  393.     public function getGalleryVideos(): Collection
  394.     {
  395.         return $this->galleryVideos;
  396.     }
  397.     public function addGalleryVideo(GalleryVideo $galleryVideo): self
  398.     {
  399.         if (!$this->galleryVideos->contains($galleryVideo)) {
  400.             $this->galleryVideos[] = $galleryVideo;
  401.             $galleryVideo->setUserProperty($this);
  402.         }
  403.         return $this;
  404.     }
  405.     public function removeGalleryVideo(GalleryVideo $galleryVideo): self
  406.     {
  407.         if ($this->galleryVideos->contains($galleryVideo)) {
  408.             $this->galleryVideos->removeElement($galleryVideo);
  409.             // set the owning side to null (unless already changed)
  410.             if ($galleryVideo->getUserProperty() === $this) {
  411.                 $galleryVideo->setUserProperty(null);
  412.             }
  413.         }
  414.         return $this;
  415.     }
  416.     /**
  417.      * @return Collection|CommunityPosts[]
  418.      */
  419.     public function getCommunityPosts(): Collection
  420.     {
  421.         return $this->communityPosts;
  422.     }
  423.     public function addCommunityPost(CommunityPosts $communityPost): self
  424.     {
  425.         if (!$this->communityPosts->contains($communityPost)) {
  426.             $this->communityPosts[] = $communityPost;
  427.             $communityPost->setUserId($this);
  428.         }
  429.         return $this;
  430.     }
  431.     public function removeCommunityPost(CommunityPosts $communityPost): self
  432.     {
  433.         if ($this->communityPosts->contains($communityPost)) {
  434.             $this->communityPosts->removeElement($communityPost);
  435.             // set the owning side to null (unless already changed)
  436.             if ($communityPost->getUserId() === $this) {
  437.                 $communityPost->setUserId(null);
  438.             }
  439.         }
  440.         return $this;
  441.     }
  442.     /**
  443.      * @return Collection|ShoppingCart[]
  444.      */
  445.     public function getShoppingCarts(): Collection
  446.     {
  447.         return $this->shoppingCarts;
  448.     }
  449.     public function addShoppingCart(ShoppingCart $shoppingCart): self
  450.     {
  451.         if (!$this->shoppingCarts->contains($shoppingCart)) {
  452.             $this->shoppingCarts[] = $shoppingCart;
  453.             $shoppingCart->setIdUser($this);
  454.         }
  455.         return $this;
  456.     }
  457.     public function removeShoppingCart(ShoppingCart $shoppingCart): self
  458.     {
  459.         if ($this->shoppingCarts->removeElement($shoppingCart)) {
  460.             // set the owning side to null (unless already changed)
  461.             if ($shoppingCart->getIdUser() === $this) {
  462.                 $shoppingCart->setIdUser(null);
  463.             }
  464.         }
  465.         return $this;
  466.     }
  467.     /**
  468.      * @return Collection|Billing[]
  469.      */
  470.     public function getBillings(): Collection
  471.     {
  472.         return $this->billings;
  473.     }
  474.     public function addBilling(Billing $billing): self
  475.     {
  476.         if (!$this->billings->contains($billing)) {
  477.             $this->billings[] = $billing;
  478.             $billing->setIdClient($this);
  479.         }
  480.         return $this;
  481.     }
  482.     public function removeBilling(Billing $billing): self
  483.     {
  484.         if ($this->billings->removeElement($billing)) {
  485.             // set the owning side to null (unless already changed)
  486.             if ($billing->getIdClient() === $this) {
  487.                 $billing->setIdClient(null);
  488.             }
  489.         }
  490.         return $this;
  491.     }
  492.     public function getRegistrationDate(): ?\DateTimeInterface
  493.     {
  494.         return $this->registrationDate;
  495.     }
  496.     public function setRegistrationDate(?\DateTimeInterface $registrationDate): self
  497.     {
  498.         $this->registrationDate $registrationDate;
  499.         return $this;
  500.     }
  501.     /**
  502.      * @return Collection|Refund[]
  503.      */
  504.     public function getRefunds(): Collection
  505.     {
  506.         return $this->refunds;
  507.     }
  508.     public function addRefund(Refund $refund): self
  509.     {
  510.         if (!$this->refunds->contains($refund)) {
  511.             $this->refunds[] = $refund;
  512.             $refund->setClient($this);
  513.         }
  514.         return $this;
  515.     }
  516.     public function removeRefund(Refund $refund): self
  517.     {
  518.         if ($this->refunds->removeElement($refund)) {
  519.             // set the owning side to null (unless already changed)
  520.             if ($refund->getClient() === $this) {
  521.                 $refund->setClient(null);
  522.             }
  523.         }
  524.         return $this;
  525.     }
  526.     public function getUserIdentifier(): string
  527.     {
  528.         return (string)$this->email;
  529.     }
  530. }