<?php
namespace App\Entity;
use App\Repository\ClientRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: ClientRepository::class)]
#[ORM\Table(name: "fos_user")]
#[Vich\Uploadable]
class Client extends User implements UserInterface,PasswordAuthenticatedUserInterface
{
const ROLE_CLIENT = 'ROLE_CLIENT';
#[ORM\Id]
#[ORM\Column(type: "integer")]
#[ORM\GeneratedValue(strategy: "AUTO")]
protected $id;
#[ORM\Column(length: 255,nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255,nullable: true)]
private ?string $surname = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $city = null;
#[ORM\ManyToOne(inversedBy: 'clients')]
private ?Country $country = null;
#[ORM\Column(nullable: true)]
private ?bool $isDeleted = false;
#[ORM\Column(type: Types::DATETIME_MUTABLE,nullable: true)]
private ?\DateTimeInterface $dateCreated = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE,nullable: true)]
private ?\DateTimeInterface $dateUpdated = null;
#[ORM\OneToOne(mappedBy: 'client', cascade: ['persist', 'remove'])]
private ?Rapper $rapper = null;
#[ORM\ManyToOne(inversedBy: 'voter')]
private ?Vote $myVotes = null;
#[ORM\Column]
private ?bool $isActive = false;
#[ORM\Column]
private ?\DateTime $activatedAt = null;
#[ORM\OneToMany(mappedBy: 'client', targetEntity: ClientActivationToken::class,cascade: ['persist', 'remove'])]
private Collection $clientActivationTokens;
#[ORM\OneToOne(mappedBy: 'client', cascade: ['persist', 'remove'])]
private ?ClientSettings $clientSettings = null;
#[ORM\OneToOne(inversedBy: 'client', cascade: ['persist', 'remove'])]
private ?BeatAuthor $author = null;
#[ORM\OneToMany(mappedBy: 'sender', targetEntity: ClientMessage::class, orphanRemoval: true)]
private Collection $clientMessagesSent;
#[ORM\OneToMany(mappedBy: 'client', targetEntity: ClientNotification::class, orphanRemoval: true)]
private Collection $clientNotifications;
#[ORM\ManyToMany(targetEntity: ClientMessage::class, mappedBy: 'recipients')]
private Collection $clientMessages;
#[ORM\ManyToMany(targetEntity: Rapper::class, mappedBy: 'followers')]
private Collection $rappersFollowed;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'referals')]
private ?self $referal = null;
#[ORM\OneToMany(mappedBy: 'referal', targetEntity: self::class)]
private Collection $referals;
#[ORM\ManyToMany(targetEntity: Beat::class, inversedBy: 'favoritedClients')]
private Collection $favoriteBeats;
#[ORM\ManyToMany(targetEntity: Battle::class, inversedBy: 'favoritedClients')]
private Collection $favoriteBattles;
#[ORM\Column(length: 255, nullable: true)]
private ?string $resetPasswordHash = null;
#[ORM\Column(nullable: true)]
private ?\DateTime $resetPasswordHashValidTo = null;
#[ORM\OneToOne(mappedBy: 'createdBy', cascade: ['persist', 'remove'])]
private ?Crew $crew = null;
#[Vich\UploadableField(mapping: 'client_image', fileNameProperty: 'imageName', size: 'imageSize')]
public ?File $imageFile = null;
#[ORM\Column(nullable: true)]
private ?string $imageName = null;
#[ORM\Column(nullable: true)]
private ?int $imageSize = null;
#[ORM\OneToMany(mappedBy: 'client', targetEntity: AuthorizationToken::class,cascade: ['persist', 'remove'])]
private Collection $authorizationTokens;
#[ORM\ManyToMany(targetEntity: BeatAuthor::class, mappedBy: 'followers')]
private Collection $followedAuthors;
#[ORM\OneToMany(mappedBy: 'sender', targetEntity: BattleComment::class)]
private Collection $battleComments;
#[ORM\OneToMany(mappedBy: 'voter', targetEntity: Vote::class)]
private Collection $myBattleVotes;
#[ORM\OneToMany(mappedBy: 'likedBy', targetEntity: BattleCommentLike::class)]
private Collection $battleCommentLikes;
public function __construct()
{
parent::__construct();
$this->clientActivationTokens = new ArrayCollection();
$this->clientMessagesSent = new ArrayCollection();
$this->clientNotifications = new ArrayCollection();
$this->clientMessages = new ArrayCollection();
$this->rappersFollowed = new ArrayCollection();
$this->referals = new ArrayCollection();
$this->favoriteBeats = new ArrayCollection();
$this->favoriteBattles = new ArrayCollection();
$this->authorizationTokens = new ArrayCollection();
$this->followedAuthors = new ArrayCollection();
$this->battleComments = new ArrayCollection();
$this->myBattleVotes = new ArrayCollection();
$this->battleCommentLikes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function getUserIdentifier(): string
{
return $this->email;
}
public function getRoles(): array
{
$roles = $this->roles;
$roles[] = self::ROLE_CLIENT; // Default role for all clients
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSurname(): ?string
{
return $this->surname;
}
public function setSurname(string $surname): self
{
$this->surname = $surname;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function isIsDeleted(): ?bool
{
return $this->isDeleted;
}
public function setIsDeleted(bool $isDeleted): self
{
$this->isDeleted = $isDeleted;
return $this;
}
public function getDateCreated(): ?\DateTimeInterface
{
return $this->dateCreated;
}
public function setDateCreated(\DateTimeInterface $dateCreated): self
{
$this->dateCreated = $dateCreated;
return $this;
}
public function getDateUpdated(): ?\DateTimeInterface
{
return $this->dateUpdated;
}
public function setDateUpdated(\DateTimeInterface $dateUpdated): self
{
$this->dateUpdated = $dateUpdated;
return $this;
}
public function getRapper(): ?Rapper
{
return $this->rapper;
}
public function setRapper(?Rapper $rapper): static
{
// unset the owning side of the relation if necessary
if ($rapper === null && $this->rapper !== null) {
$this->rapper->setClient(null);
}
// set the owning side of the relation if necessary
if ($rapper !== null && $rapper->getClient() !== $this) {
$rapper->setClient($this);
}
$this->rapper = $rapper;
return $this;
}
public function isIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): static
{
$this->isActive = $isActive;
return $this;
}
public function getActivatedAt(): ?\DateTime
{
return $this->activatedAt;
}
public function setActivatedAt(\DateTime $activatedAt): static
{
$this->activatedAt = $activatedAt;
return $this;
}
/**
* @return Collection<int, ClientActivationToken>
*/
public function getClientActivationTokens(): Collection
{
return $this->clientActivationTokens;
}
public function addClientActivationToken(ClientActivationToken $clientActivationToken): static
{
if (!$this->clientActivationTokens->contains($clientActivationToken)) {
$this->clientActivationTokens->add($clientActivationToken);
$clientActivationToken->setClient($this);
}
return $this;
}
public function removeClientActivationToken(ClientActivationToken $clientActivationToken): static
{
if ($this->clientActivationTokens->removeElement($clientActivationToken)) {
// set the owning side to null (unless already changed)
if ($clientActivationToken->getClient() === $this) {
$clientActivationToken->setClient(null);
}
}
return $this;
}
public function getClientSettings(): ?ClientSettings
{
return $this->clientSettings;
}
public function setClientSettings(ClientSettings $clientSettings): static
{
// set the owning side of the relation if necessary
if ($clientSettings->getClient() !== $this) {
$clientSettings->setClient($this);
}
$this->clientSettings = $clientSettings;
return $this;
}
public function getAuthor(): ?BeatAuthor
{
return $this->author;
}
public function setAuthor(?BeatAuthor $author): static
{
$this->author = $author;
return $this;
}
/**
* @return Collection<int, ClientMessage>
*/
public function getClientMessagesSent(): Collection
{
return $this->clientMessagesSent;
}
public function addClientMessagesSent(ClientMessage $clientMessagesSent): static
{
if (!$this->clientMessagesSent->contains($clientMessagesSent)) {
$this->clientMessagesSent->add($clientMessagesSent);
$clientMessagesSent->setSender($this);
}
return $this;
}
public function removeClientMessagesSent(ClientMessage $clientMessagesSent): static
{
if ($this->clientMessagesSent->removeElement($clientMessagesSent)) {
// set the owning side to null (unless already changed)
if ($clientMessagesSent->getSender() === $this) {
$clientMessagesSent->setSender(null);
}
}
return $this;
}
/**
* @return Collection<int, ClientNotification>
*/
public function getClientNotifications(): Collection
{
return $this->clientNotifications;
}
public function addClientNotification(ClientNotification $clientNotification): static
{
if (!$this->clientNotifications->contains($clientNotification)) {
$this->clientNotifications->add($clientNotification);
$clientNotification->setClient($this);
}
return $this;
}
public function removeClientNotification(ClientNotification $clientNotification): static
{
if ($this->clientNotifications->removeElement($clientNotification)) {
// set the owning side to null (unless already changed)
if ($clientNotification->getClient() === $this) {
$clientNotification->setClient(null);
}
}
return $this;
}
/**
* @return Collection<int, ClientMessage>
*/
public function getClientMessages(): Collection
{
return $this->clientMessages;
}
public function addClientMessage(ClientMessage $clientMessage): static
{
if (!$this->clientMessages->contains($clientMessage)) {
$this->clientMessages->add($clientMessage);
$clientMessage->addRecipient($this);
}
return $this;
}
public function removeClientMessage(ClientMessage $clientMessage): static
{
if ($this->clientMessages->removeElement($clientMessage)) {
$clientMessage->removeRecipient($this);
}
return $this;
}
/**
* @return Collection<int, Rapper>
*/
public function getRappersFollowed(): Collection
{
return $this->rappersFollowed;
}
public function addRappersFollowed(Rapper $rappersFollowed): static
{
if (!$this->rappersFollowed->contains($rappersFollowed)) {
$this->rappersFollowed->add($rappersFollowed);
$rappersFollowed->addFollower($this);
}
return $this;
}
public function removeRappersFollowed(Rapper $rappersFollowed): static
{
if ($this->rappersFollowed->removeElement($rappersFollowed)) {
$rappersFollowed->removeFollower($this);
}
return $this;
}
public function getReferal(): ?self
{
return $this->referal;
}
public function setReferal(?self $referal): static
{
$this->referal = $referal;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getReferals(): Collection
{
return $this->referals;
}
public function addReferal(self $referal): static
{
if (!$this->referals->contains($referal)) {
$this->referals->add($referal);
$referal->setReferal($this);
}
return $this;
}
public function removeReferal(self $referal): static
{
if ($this->referals->removeElement($referal)) {
// set the owning side to null (unless already changed)
if ($referal->getReferal() === $this) {
$referal->setReferal(null);
}
}
return $this;
}
/**
* @return Collection<int, Beat>
*/
public function getFavoriteBeats(): Collection
{
return $this->favoriteBeats;
}
public function addFavoriteBeat(Beat $favoriteBeat): static
{
if (!$this->favoriteBeats->contains($favoriteBeat)) {
$this->favoriteBeats->add($favoriteBeat);
}
return $this;
}
public function removeFavoriteBeat(Beat $favoriteBeat): static
{
$this->favoriteBeats->removeElement($favoriteBeat);
return $this;
}
/**
* @return Collection<int, Battle>
*/
public function getFavoriteBattles(): Collection
{
return $this->favoriteBattles;
}
public function addFavoriteBattle(Battle $favoriteBattle): static
{
if (!$this->favoriteBattles->contains($favoriteBattle)) {
$this->favoriteBattles->add($favoriteBattle);
}
return $this;
}
public function removeFavoriteBattle(Battle $favoriteBattle): static
{
$this->favoriteBattles->removeElement($favoriteBattle);
return $this;
}
public function getResetPasswordHash(): ?string
{
return $this->resetPasswordHash;
}
public function setResetPasswordHash(?string $resetPasswordHash): static
{
$this->resetPasswordHash = $resetPasswordHash;
return $this;
}
public function getResetPasswordHashValidTo(): ?\DateTime
{
return $this->resetPasswordHashValidTo;
}
public function setResetPasswordHashValidTo(?\DateTime $resetPasswordHashValidTo): static
{
$this->resetPasswordHashValidTo = $resetPasswordHashValidTo;
return $this;
}
public function getCrew(): ?Crew
{
return $this->crew;
}
public function setCrew(?Crew $crew): static
{
// unset the owning side of the relation if necessary
if ($crew === null && $this->crew !== null) {
$this->crew->setCreatedBy(null);
}
// set the owning side of the relation if necessary
if ($crew !== null && $crew->getCreatedBy() !== $this) {
$crew->setCreatedBy($this);
}
$this->crew = $crew;
return $this;
}
public function setImageFile(?File $imageFile = null): void
{
$this->imageFile = $imageFile;
if ($this->imageFile instanceof UploadedFile) {
$this->dateUpdated = new \DateTime('now');
}
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function setImageName(?string $imageName): void
{
$this->imageName = $imageName;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageSize(?int $imageSize): void
{
$this->imageSize = $imageSize;
}
public function getAvatarSize(): ?int
{
return $this->imageSize;
}
/**
* @return Collection<int, AuthorizationToken>
*/
public function getAuthorizationTokens(): Collection
{
return $this->authorizationTokens;
}
public function addAuthorizationToken(AuthorizationToken $authorizationToken): static
{
if (!$this->authorizationTokens->contains($authorizationToken)) {
$this->authorizationTokens->add($authorizationToken);
$authorizationToken->setClient($this);
}
return $this;
}
public function removeAuthorizationToken(AuthorizationToken $authorizationToken): static
{
if ($this->authorizationTokens->removeElement($authorizationToken)) {
// set the owning side to null (unless already changed)
if ($authorizationToken->getClient() === $this) {
$authorizationToken->setClient(null);
}
}
return $this;
}
/**
* @return Collection<int, BeatAuthor>
*/
public function getFollowedAuthors(): Collection
{
return $this->followedAuthors;
}
public function addFollowedAuthor(BeatAuthor $followedAuthor): static
{
if (!$this->followedAuthors->contains($followedAuthor)) {
$this->followedAuthors->add($followedAuthor);
$followedAuthor->addFollower($this);
}
return $this;
}
public function removeFollowedAuthor(BeatAuthor $followedAuthor): static
{
if ($this->followedAuthors->removeElement($followedAuthor)) {
$followedAuthor->removeFollower($this);
}
return $this;
}
/**
* @return Collection<int, BattleComment>
*/
public function getBattleComments(): Collection
{
return $this->battleComments;
}
public function addBattleComment(BattleComment $battleComment): static
{
if (!$this->battleComments->contains($battleComment)) {
$this->battleComments->add($battleComment);
$battleComment->setSender($this);
}
return $this;
}
public function removeBattleComment(BattleComment $battleComment): static
{
if ($this->battleComments->removeElement($battleComment)) {
// set the owning side to null (unless already changed)
if ($battleComment->getSender() === $this) {
$battleComment->setSender(null);
}
}
return $this;
}
/**
* @return Collection<int, Vote>
*/
public function getMyBattleVotes(): Collection
{
return $this->myBattleVotes;
}
public function addMyBattleVote(Vote $myBattleVote): static
{
if (!$this->myBattleVotes->contains($myBattleVote)) {
$this->myBattleVotes->add($myBattleVote);
$myBattleVote->setVoter($this);
}
return $this;
}
public function removeMyBattleVote(Vote $myBattleVote): static
{
if ($this->myBattleVotes->removeElement($myBattleVote)) {
// set the owning side to null (unless already changed)
if ($myBattleVote->getVoter() === $this) {
$myBattleVote->setVoter(null);
}
}
return $this;
}
/**
* @return Collection<int, BattleCommentLike>
*/
public function getBattleCommentLikes(): Collection
{
return $this->battleCommentLikes;
}
public function addBattleCommentLike(BattleCommentLike $battleCommentLike): static
{
if (!$this->battleCommentLikes->contains($battleCommentLike)) {
$this->battleCommentLikes->add($battleCommentLike);
$battleCommentLike->setLikedBy($this);
}
return $this;
}
public function removeBattleCommentLike(BattleCommentLike $battleCommentLike): static
{
if ($this->battleCommentLikes->removeElement($battleCommentLike)) {
// set the owning side to null (unless already changed)
if ($battleCommentLike->getLikedBy() === $this) {
$battleCommentLike->setLikedBy(null);
}
}
return $this;
}
}