src/Entity/Client.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClientRepository;
  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 FOS\UserBundle\Model\User;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\HttpFoundation\File\UploadedFile;
  11. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  12. use Symfony\Component\Security\Core\User\UserInterface;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. #[ORM\Entity(repositoryClassClientRepository::class)]
  15. #[ORM\Table(name"fos_user")]
  16. #[Vich\Uploadable]
  17. class Client extends User implements UserInterface,PasswordAuthenticatedUserInterface
  18. {
  19.     const ROLE_CLIENT 'ROLE_CLIENT';
  20.     #[ORM\Id]
  21.     #[ORM\Column(type"integer")]
  22.     #[ORM\GeneratedValue(strategy"AUTO")]
  23.     protected $id;
  24.     #[ORM\Column(length255,nullabletrue)]
  25.     private ?string $name null;
  26.     #[ORM\Column(length255,nullabletrue)]
  27.     private ?string $surname null;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $city null;
  30.     #[ORM\ManyToOne(inversedBy'clients')]
  31.     private ?Country $country null;
  32.     #[ORM\Column(nullabletrue)]
  33.     private ?bool $isDeleted false;
  34.     #[ORM\Column(typeTypes::DATETIME_MUTABLE,nullabletrue)]
  35.     private ?\DateTimeInterface $dateCreated null;
  36.     #[ORM\Column(typeTypes::DATETIME_MUTABLE,nullabletrue)]
  37.     private ?\DateTimeInterface $dateUpdated null;
  38.     #[ORM\OneToOne(mappedBy'client'cascade: ['persist''remove'])]
  39.     private ?Rapper $rapper null;
  40.     #[ORM\ManyToOne(inversedBy'voter')]
  41.     private ?Vote $myVotes null;
  42.     #[ORM\Column]
  43.     private ?bool $isActive false;
  44.     #[ORM\Column]
  45.     private ?\DateTime $activatedAt null;
  46.     #[ORM\OneToMany(mappedBy'client'targetEntityClientActivationToken::class,cascade: ['persist''remove'])]
  47.     private Collection $clientActivationTokens;
  48.     #[ORM\OneToOne(mappedBy'client'cascade: ['persist''remove'])]
  49.     private ?ClientSettings $clientSettings null;
  50.     #[ORM\OneToOne(inversedBy'client'cascade: ['persist''remove'])]
  51.     private ?BeatAuthor $author null;
  52.     #[ORM\OneToMany(mappedBy'sender'targetEntityClientMessage::class, orphanRemovaltrue)]
  53.     private Collection $clientMessagesSent;
  54.     #[ORM\OneToMany(mappedBy'client'targetEntityClientNotification::class, orphanRemovaltrue)]
  55.     private Collection $clientNotifications;
  56.     #[ORM\ManyToMany(targetEntityClientMessage::class, mappedBy'recipients')]
  57.     private Collection $clientMessages;
  58.     #[ORM\ManyToMany(targetEntityRapper::class, mappedBy'followers')]
  59.     private Collection $rappersFollowed;
  60.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'referals')]
  61.     private ?self $referal null;
  62.     #[ORM\OneToMany(mappedBy'referal'targetEntityself::class)]
  63.     private Collection $referals;
  64.     #[ORM\ManyToMany(targetEntityBeat::class, inversedBy'favoritedClients')]
  65.     private Collection $favoriteBeats;
  66.     #[ORM\ManyToMany(targetEntityBattle::class, inversedBy'favoritedClients')]
  67.     private Collection $favoriteBattles;
  68.     #[ORM\Column(length255nullabletrue)]
  69.     private ?string $resetPasswordHash null;
  70.     #[ORM\Column(nullabletrue)]
  71.     private ?\DateTime $resetPasswordHashValidTo null;
  72.     #[ORM\OneToOne(mappedBy'createdBy'cascade: ['persist''remove'])]
  73.     private ?Crew $crew null;
  74.     #[Vich\UploadableField(mapping'client_image'fileNameProperty'imageName'size'imageSize')]
  75.     public ?File $imageFile null;
  76.     #[ORM\Column(nullabletrue)]
  77.     private ?string $imageName null;
  78.     #[ORM\Column(nullabletrue)]
  79.     private ?int $imageSize null;
  80.     #[ORM\OneToMany(mappedBy'client'targetEntityAuthorizationToken::class,cascade: ['persist''remove'])]
  81.     private Collection $authorizationTokens;
  82.     #[ORM\ManyToMany(targetEntityBeatAuthor::class, mappedBy'followers')]
  83.     private Collection $followedAuthors;
  84.     #[ORM\OneToMany(mappedBy'sender'targetEntityBattleComment::class)]
  85.     private Collection $battleComments;
  86.     #[ORM\OneToMany(mappedBy'voter'targetEntityVote::class)]
  87.     private Collection $myBattleVotes;
  88.     #[ORM\OneToMany(mappedBy'likedBy'targetEntityBattleCommentLike::class)]
  89.     private Collection $battleCommentLikes;
  90.     public function __construct()
  91.     {
  92.         parent::__construct();
  93.         $this->clientActivationTokens = new ArrayCollection();
  94.         $this->clientMessagesSent = new ArrayCollection();
  95.         $this->clientNotifications = new ArrayCollection();
  96.         $this->clientMessages = new ArrayCollection();
  97.         $this->rappersFollowed = new ArrayCollection();
  98.         $this->referals = new ArrayCollection();
  99.         $this->favoriteBeats = new ArrayCollection();
  100.         $this->favoriteBattles = new ArrayCollection();
  101.         $this->authorizationTokens = new ArrayCollection();
  102.         $this->followedAuthors = new ArrayCollection();
  103.         $this->battleComments = new ArrayCollection();
  104.         $this->myBattleVotes = new ArrayCollection();
  105.         $this->battleCommentLikes = new ArrayCollection();
  106.     }
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     public function getEmail(): ?string
  112.     {
  113.         return $this->email;
  114.     }
  115.     public function getUserIdentifier(): string
  116.     {
  117.         return $this->email;
  118.     }
  119.     public function getRoles(): array
  120.     {
  121.         $roles $this->roles;
  122.         $roles[] = self::ROLE_CLIENT// Default role for all clients
  123.         return array_unique($roles);
  124.     }
  125.     public function setRoles(array $roles): self
  126.     {
  127.         $this->roles $roles;
  128.         return $this;
  129.     }
  130.     public function eraseCredentials()
  131.     {
  132.         // If you store any temporary, sensitive data on the user, clear it here
  133.     }
  134.     /**
  135.      * @see PasswordAuthenticatedUserInterface
  136.      */
  137.     public function getPassword(): string
  138.     {
  139.         return $this->password;
  140.     }
  141.     public function getName(): ?string
  142.     {
  143.         return $this->name;
  144.     }
  145.     public function setName(string $name): self
  146.     {
  147.         $this->name $name;
  148.         return $this;
  149.     }
  150.     public function getSurname(): ?string
  151.     {
  152.         return $this->surname;
  153.     }
  154.     public function setSurname(string $surname): self
  155.     {
  156.         $this->surname $surname;
  157.         return $this;
  158.     }
  159.     public function getCity(): ?string
  160.     {
  161.         return $this->city;
  162.     }
  163.     public function setCity(?string $city): self
  164.     {
  165.         $this->city $city;
  166.         return $this;
  167.     }
  168.     public function getCountry(): ?Country
  169.     {
  170.         return $this->country;
  171.     }
  172.     public function setCountry(?Country $country): self
  173.     {
  174.         $this->country $country;
  175.         return $this;
  176.     }
  177.     public function isIsDeleted(): ?bool
  178.     {
  179.         return $this->isDeleted;
  180.     }
  181.     public function setIsDeleted(bool $isDeleted): self
  182.     {
  183.         $this->isDeleted $isDeleted;
  184.         return $this;
  185.     }
  186.     public function getDateCreated(): ?\DateTimeInterface
  187.     {
  188.         return $this->dateCreated;
  189.     }
  190.     public function setDateCreated(\DateTimeInterface $dateCreated): self
  191.     {
  192.         $this->dateCreated $dateCreated;
  193.         return $this;
  194.     }
  195.     public function getDateUpdated(): ?\DateTimeInterface
  196.     {
  197.         return $this->dateUpdated;
  198.     }
  199.     public function setDateUpdated(\DateTimeInterface $dateUpdated): self
  200.     {
  201.         $this->dateUpdated $dateUpdated;
  202.         return $this;
  203.     }
  204.     public function getRapper(): ?Rapper
  205.     {
  206.         return $this->rapper;
  207.     }
  208.     public function setRapper(?Rapper $rapper): static
  209.     {
  210.         // unset the owning side of the relation if necessary
  211.         if ($rapper === null && $this->rapper !== null) {
  212.             $this->rapper->setClient(null);
  213.         }
  214.         // set the owning side of the relation if necessary
  215.         if ($rapper !== null && $rapper->getClient() !== $this) {
  216.             $rapper->setClient($this);
  217.         }
  218.         $this->rapper $rapper;
  219.         return $this;
  220.     }
  221.     public function isIsActive(): ?bool
  222.     {
  223.         return $this->isActive;
  224.     }
  225.     public function setIsActive(bool $isActive): static
  226.     {
  227.         $this->isActive $isActive;
  228.         return $this;
  229.     }
  230.     public function getActivatedAt(): ?\DateTime
  231.     {
  232.         return $this->activatedAt;
  233.     }
  234.     public function setActivatedAt(\DateTime $activatedAt): static
  235.     {
  236.         $this->activatedAt $activatedAt;
  237.         return $this;
  238.     }
  239.     /**
  240.      * @return Collection<int, ClientActivationToken>
  241.      */
  242.     public function getClientActivationTokens(): Collection
  243.     {
  244.         return $this->clientActivationTokens;
  245.     }
  246.     public function addClientActivationToken(ClientActivationToken $clientActivationToken): static
  247.     {
  248.         if (!$this->clientActivationTokens->contains($clientActivationToken)) {
  249.             $this->clientActivationTokens->add($clientActivationToken);
  250.             $clientActivationToken->setClient($this);
  251.         }
  252.         return $this;
  253.     }
  254.     public function removeClientActivationToken(ClientActivationToken $clientActivationToken): static
  255.     {
  256.         if ($this->clientActivationTokens->removeElement($clientActivationToken)) {
  257.             // set the owning side to null (unless already changed)
  258.             if ($clientActivationToken->getClient() === $this) {
  259.                 $clientActivationToken->setClient(null);
  260.             }
  261.         }
  262.         return $this;
  263.     }
  264.     public function getClientSettings(): ?ClientSettings
  265.     {
  266.         return $this->clientSettings;
  267.     }
  268.     public function setClientSettings(ClientSettings $clientSettings): static
  269.     {
  270.         // set the owning side of the relation if necessary
  271.         if ($clientSettings->getClient() !== $this) {
  272.             $clientSettings->setClient($this);
  273.         }
  274.         $this->clientSettings $clientSettings;
  275.         return $this;
  276.     }
  277.     public function getAuthor(): ?BeatAuthor
  278.     {
  279.         return $this->author;
  280.     }
  281.     public function setAuthor(?BeatAuthor $author): static
  282.     {
  283.         $this->author $author;
  284.         return $this;
  285.     }
  286.     /**
  287.      * @return Collection<int, ClientMessage>
  288.      */
  289.     public function getClientMessagesSent(): Collection
  290.     {
  291.         return $this->clientMessagesSent;
  292.     }
  293.     public function addClientMessagesSent(ClientMessage $clientMessagesSent): static
  294.     {
  295.         if (!$this->clientMessagesSent->contains($clientMessagesSent)) {
  296.             $this->clientMessagesSent->add($clientMessagesSent);
  297.             $clientMessagesSent->setSender($this);
  298.         }
  299.         return $this;
  300.     }
  301.     public function removeClientMessagesSent(ClientMessage $clientMessagesSent): static
  302.     {
  303.         if ($this->clientMessagesSent->removeElement($clientMessagesSent)) {
  304.             // set the owning side to null (unless already changed)
  305.             if ($clientMessagesSent->getSender() === $this) {
  306.                 $clientMessagesSent->setSender(null);
  307.             }
  308.         }
  309.         return $this;
  310.     }
  311.     /**
  312.      * @return Collection<int, ClientNotification>
  313.      */
  314.     public function getClientNotifications(): Collection
  315.     {
  316.         return $this->clientNotifications;
  317.     }
  318.     public function addClientNotification(ClientNotification $clientNotification): static
  319.     {
  320.         if (!$this->clientNotifications->contains($clientNotification)) {
  321.             $this->clientNotifications->add($clientNotification);
  322.             $clientNotification->setClient($this);
  323.         }
  324.         return $this;
  325.     }
  326.     public function removeClientNotification(ClientNotification $clientNotification): static
  327.     {
  328.         if ($this->clientNotifications->removeElement($clientNotification)) {
  329.             // set the owning side to null (unless already changed)
  330.             if ($clientNotification->getClient() === $this) {
  331.                 $clientNotification->setClient(null);
  332.             }
  333.         }
  334.         return $this;
  335.     }
  336.     /**
  337.      * @return Collection<int, ClientMessage>
  338.      */
  339.     public function getClientMessages(): Collection
  340.     {
  341.         return $this->clientMessages;
  342.     }
  343.     public function addClientMessage(ClientMessage $clientMessage): static
  344.     {
  345.         if (!$this->clientMessages->contains($clientMessage)) {
  346.             $this->clientMessages->add($clientMessage);
  347.             $clientMessage->addRecipient($this);
  348.         }
  349.         return $this;
  350.     }
  351.     public function removeClientMessage(ClientMessage $clientMessage): static
  352.     {
  353.         if ($this->clientMessages->removeElement($clientMessage)) {
  354.             $clientMessage->removeRecipient($this);
  355.         }
  356.         return $this;
  357.     }
  358.     /**
  359.      * @return Collection<int, Rapper>
  360.      */
  361.     public function getRappersFollowed(): Collection
  362.     {
  363.         return $this->rappersFollowed;
  364.     }
  365.     public function addRappersFollowed(Rapper $rappersFollowed): static
  366.     {
  367.         if (!$this->rappersFollowed->contains($rappersFollowed)) {
  368.             $this->rappersFollowed->add($rappersFollowed);
  369.             $rappersFollowed->addFollower($this);
  370.         }
  371.         return $this;
  372.     }
  373.     public function removeRappersFollowed(Rapper $rappersFollowed): static
  374.     {
  375.         if ($this->rappersFollowed->removeElement($rappersFollowed)) {
  376.             $rappersFollowed->removeFollower($this);
  377.         }
  378.         return $this;
  379.     }
  380.     public function getReferal(): ?self
  381.     {
  382.         return $this->referal;
  383.     }
  384.     public function setReferal(?self $referal): static
  385.     {
  386.         $this->referal $referal;
  387.         return $this;
  388.     }
  389.     /**
  390.      * @return Collection<int, self>
  391.      */
  392.     public function getReferals(): Collection
  393.     {
  394.         return $this->referals;
  395.     }
  396.     public function addReferal(self $referal): static
  397.     {
  398.         if (!$this->referals->contains($referal)) {
  399.             $this->referals->add($referal);
  400.             $referal->setReferal($this);
  401.         }
  402.         return $this;
  403.     }
  404.     public function removeReferal(self $referal): static
  405.     {
  406.         if ($this->referals->removeElement($referal)) {
  407.             // set the owning side to null (unless already changed)
  408.             if ($referal->getReferal() === $this) {
  409.                 $referal->setReferal(null);
  410.             }
  411.         }
  412.         return $this;
  413.     }
  414.     /**
  415.      * @return Collection<int, Beat>
  416.      */
  417.     public function getFavoriteBeats(): Collection
  418.     {
  419.         return $this->favoriteBeats;
  420.     }
  421.     public function addFavoriteBeat(Beat $favoriteBeat): static
  422.     {
  423.         if (!$this->favoriteBeats->contains($favoriteBeat)) {
  424.             $this->favoriteBeats->add($favoriteBeat);
  425.         }
  426.         return $this;
  427.     }
  428.     public function removeFavoriteBeat(Beat $favoriteBeat): static
  429.     {
  430.         $this->favoriteBeats->removeElement($favoriteBeat);
  431.         return $this;
  432.     }
  433.     /**
  434.      * @return Collection<int, Battle>
  435.      */
  436.     public function getFavoriteBattles(): Collection
  437.     {
  438.         return $this->favoriteBattles;
  439.     }
  440.     public function addFavoriteBattle(Battle $favoriteBattle): static
  441.     {
  442.         if (!$this->favoriteBattles->contains($favoriteBattle)) {
  443.             $this->favoriteBattles->add($favoriteBattle);
  444.         }
  445.         return $this;
  446.     }
  447.     public function removeFavoriteBattle(Battle $favoriteBattle): static
  448.     {
  449.         $this->favoriteBattles->removeElement($favoriteBattle);
  450.         return $this;
  451.     }
  452.     public function getResetPasswordHash(): ?string
  453.     {
  454.         return $this->resetPasswordHash;
  455.     }
  456.     public function setResetPasswordHash(?string $resetPasswordHash): static
  457.     {
  458.         $this->resetPasswordHash $resetPasswordHash;
  459.         return $this;
  460.     }
  461.     public function getResetPasswordHashValidTo(): ?\DateTime
  462.     {
  463.         return $this->resetPasswordHashValidTo;
  464.     }
  465.     public function setResetPasswordHashValidTo(?\DateTime $resetPasswordHashValidTo): static
  466.     {
  467.         $this->resetPasswordHashValidTo $resetPasswordHashValidTo;
  468.         return $this;
  469.     }
  470.     public function getCrew(): ?Crew
  471.     {
  472.         return $this->crew;
  473.     }
  474.     public function setCrew(?Crew $crew): static
  475.     {
  476.         // unset the owning side of the relation if necessary
  477.         if ($crew === null && $this->crew !== null) {
  478.             $this->crew->setCreatedBy(null);
  479.         }
  480.         // set the owning side of the relation if necessary
  481.         if ($crew !== null && $crew->getCreatedBy() !== $this) {
  482.             $crew->setCreatedBy($this);
  483.         }
  484.         $this->crew $crew;
  485.         return $this;
  486.     }
  487.     public function setImageFile(?File $imageFile null): void
  488.     {
  489.         $this->imageFile $imageFile;
  490.         if ($this->imageFile instanceof UploadedFile) {
  491.             $this->dateUpdated = new \DateTime('now');
  492.         }
  493.     }
  494.     public function getImageFile(): ?File
  495.     {
  496.         return $this->imageFile;
  497.     }
  498.     public function setImageName(?string $imageName): void
  499.     {
  500.         $this->imageName $imageName;
  501.     }
  502.     public function getImageName(): ?string
  503.     {
  504.         return $this->imageName;
  505.     }
  506.     public function setImageSize(?int $imageSize): void
  507.     {
  508.         $this->imageSize $imageSize;
  509.     }
  510.     public function getAvatarSize(): ?int
  511.     {
  512.         return $this->imageSize;
  513.     }
  514.     /**
  515.      * @return Collection<int, AuthorizationToken>
  516.      */
  517.     public function getAuthorizationTokens(): Collection
  518.     {
  519.         return $this->authorizationTokens;
  520.     }
  521.     public function addAuthorizationToken(AuthorizationToken $authorizationToken): static
  522.     {
  523.         if (!$this->authorizationTokens->contains($authorizationToken)) {
  524.             $this->authorizationTokens->add($authorizationToken);
  525.             $authorizationToken->setClient($this);
  526.         }
  527.         return $this;
  528.     }
  529.     public function removeAuthorizationToken(AuthorizationToken $authorizationToken): static
  530.     {
  531.         if ($this->authorizationTokens->removeElement($authorizationToken)) {
  532.             // set the owning side to null (unless already changed)
  533.             if ($authorizationToken->getClient() === $this) {
  534.                 $authorizationToken->setClient(null);
  535.             }
  536.         }
  537.         return $this;
  538.     }
  539.     /**
  540.      * @return Collection<int, BeatAuthor>
  541.      */
  542.     public function getFollowedAuthors(): Collection
  543.     {
  544.         return $this->followedAuthors;
  545.     }
  546.     public function addFollowedAuthor(BeatAuthor $followedAuthor): static
  547.     {
  548.         if (!$this->followedAuthors->contains($followedAuthor)) {
  549.             $this->followedAuthors->add($followedAuthor);
  550.             $followedAuthor->addFollower($this);
  551.         }
  552.         return $this;
  553.     }
  554.     public function removeFollowedAuthor(BeatAuthor $followedAuthor): static
  555.     {
  556.         if ($this->followedAuthors->removeElement($followedAuthor)) {
  557.             $followedAuthor->removeFollower($this);
  558.         }
  559.         return $this;
  560.     }
  561.     /**
  562.      * @return Collection<int, BattleComment>
  563.      */
  564.     public function getBattleComments(): Collection
  565.     {
  566.         return $this->battleComments;
  567.     }
  568.     public function addBattleComment(BattleComment $battleComment): static
  569.     {
  570.         if (!$this->battleComments->contains($battleComment)) {
  571.             $this->battleComments->add($battleComment);
  572.             $battleComment->setSender($this);
  573.         }
  574.         return $this;
  575.     }
  576.     public function removeBattleComment(BattleComment $battleComment): static
  577.     {
  578.         if ($this->battleComments->removeElement($battleComment)) {
  579.             // set the owning side to null (unless already changed)
  580.             if ($battleComment->getSender() === $this) {
  581.                 $battleComment->setSender(null);
  582.             }
  583.         }
  584.         return $this;
  585.     }
  586.     /**
  587.      * @return Collection<int, Vote>
  588.      */
  589.     public function getMyBattleVotes(): Collection
  590.     {
  591.         return $this->myBattleVotes;
  592.     }
  593.     public function addMyBattleVote(Vote $myBattleVote): static
  594.     {
  595.         if (!$this->myBattleVotes->contains($myBattleVote)) {
  596.             $this->myBattleVotes->add($myBattleVote);
  597.             $myBattleVote->setVoter($this);
  598.         }
  599.         return $this;
  600.     }
  601.     public function removeMyBattleVote(Vote $myBattleVote): static
  602.     {
  603.         if ($this->myBattleVotes->removeElement($myBattleVote)) {
  604.             // set the owning side to null (unless already changed)
  605.             if ($myBattleVote->getVoter() === $this) {
  606.                 $myBattleVote->setVoter(null);
  607.             }
  608.         }
  609.         return $this;
  610.     }
  611.     /**
  612.      * @return Collection<int, BattleCommentLike>
  613.      */
  614.     public function getBattleCommentLikes(): Collection
  615.     {
  616.         return $this->battleCommentLikes;
  617.     }
  618.     public function addBattleCommentLike(BattleCommentLike $battleCommentLike): static
  619.     {
  620.         if (!$this->battleCommentLikes->contains($battleCommentLike)) {
  621.             $this->battleCommentLikes->add($battleCommentLike);
  622.             $battleCommentLike->setLikedBy($this);
  623.         }
  624.         return $this;
  625.     }
  626.     public function removeBattleCommentLike(BattleCommentLike $battleCommentLike): static
  627.     {
  628.         if ($this->battleCommentLikes->removeElement($battleCommentLike)) {
  629.             // set the owning side to null (unless already changed)
  630.             if ($battleCommentLike->getLikedBy() === $this) {
  631.                 $battleCommentLike->setLikedBy(null);
  632.             }
  633.         }
  634.         return $this;
  635.     }
  636. }