src/Entity/User.php line 28
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use App\Repository\UserRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;use Scheb\TwoFactorBundle\Model\TrustedDeviceInterface;use Symfony\Component\Serializer\Annotation\Groups;use ApiPlatform\Metadata\Delete;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Metadata\Link;use ApiPlatform\Metadata\Patch;use ApiPlatform\Metadata\Post;use ApiPlatform\Metadata\Put;#[ORM\Entity(repositoryClass: UserRepository::class)]#[ApiResource]#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]class User implements UserInterface, PasswordAuthenticatedUserInterface, TwoFactorInterface, TrustedDeviceInterface{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['user:read','service:read','reservation:read','serviceswithoutuserservices:read','notification:read'])]private ?int $id = null;#[ORM\Column(length: 255, nullable: true)]private ?string $gender = null;#[ORM\Column(length: 255)]#[Groups(['user:read','service:read','reservation:read','serviceswithoutuserservices:read','notification:read'])]private ?string $fname = null;#[ORM\Column(length: 255)]#[Groups(['user:read','service:read','reservation:read','serviceswithoutuserservices:read','notification:read'])]private ?string $lname = null;#[ORM\Column(length: 255)]#[Groups(['service:read','reservation:read','serviceswithoutuserservices:read','notification:read'])]private ?string $email = null;#[ORM\Column(length: 255, nullable: true)]private ?string $email_token = null;#[ORM\Column(length: 255, nullable: true)]private ?string $username = null;#[ORM\Column(length: 255, nullable: true)]private ?string $password = null;#[ORM\Column(length: 255, nullable: true)]private ?string $password_token = null;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $birthday = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['user:read','service:read','reservation:read','serviceswithoutuserservices:read','notification:read'])]private ?string $phone = null;#[ORM\Column(length: 255, nullable: true)]private ?string $phone_token = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['user:read','service:read','reservation:read','notification:read'])]private ?string $avatar = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['user:read','service:read','reservation:read','notification:read'])]private ?string $type = "1";#[ORM\Column]private ?int $status = 0;#[ORM\Column]private array $roles = [];#[ORM\Column(length: 255, nullable: true)]private ?string $lang = null;#[ORM\Column(length: 255, nullable: true)]private ?string $address1 = null;#[ORM\Column(length: 255, nullable: true)]private ?string $address2 = null;#[ORM\Column(length: 255, nullable: true)]private ?string $zipcode = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['service:read'])]private ?string $city = null;#[ORM\Column(length: 255, nullable: true)]private ?string $social_brand = null;#[ORM\Column(length: 255, nullable: true)]private ?string $social_id = null;#[ORM\Column(length: 255, nullable: true)]private ?string $country = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private ?\DateTimeInterface $created_at = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $updated_at = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $last_login = null;#[ORM\Column(type: Types::INTEGER)]private int $trustedVersion = 0;private ?string $password_update = null;#[ORM\Column(type: 'boolean')]private $isVerified = false;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $description = null;#[ORM\Column(length: 255, nullable: true)]private ?string $location = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Media::class, orphanRemoval: true)]private Collection $medias;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Price::class, orphanRemoval: true)]private Collection $prices;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Service::class)]private Collection $services;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Reservation::class)]private Collection $reservations;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Notification::class)]private Collection $notifications;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Favorite::class)]private Collection $favorites;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Gallery::class)]#[Groups(['service:read'])]private Collection $galleries;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Review::class)]private Collection $reviews;#[ORM\OneToMany(mappedBy: 'sender', targetEntity: Message::class)]private Collection $messages;#[ORM\Column(length: 255, nullable: true)]private ?string $expoPushToken = null;#[ORM\Column(length: 255, nullable: true)]private ?string $identity = null;public function __construct(){$this->setCreatedAt(new \DateTime());$this->medias = new ArrayCollection();$this->prices = new ArrayCollection();$this->services = new ArrayCollection();$this->reservations = new ArrayCollection();$this->notifications = new ArrayCollection();$this->favorites = new ArrayCollection();$this->galleries = new ArrayCollection();$this->reviews = new ArrayCollection();$this->messages = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getGender(): ?string{return $this->gender;}public function setGender(?string $gender): self{$this->gender = $gender;return $this;}public function getFname(): ?string{return $this->fname;}public function setFname(string $fname): self{$this->fname = $fname;return $this;}public function getLname(): ?string{return $this->lname;}public function setLname(string $lname): self{$this->lname = $lname;return $this;}public function getEmail(): ?string{return $this->email;}public function setEmail(string $email): self{$this->email = $email;return $this;}public function getUsername(): ?string{return $this->email;}public function setUsername(?string $username): self{$this->username = $username;return $this;}public function getPassword(): ?string{return $this->password;}public function setPassword(?string $password): self{$this->password = $password;return $this;}public function getPasswordToken(): ?string{return $this->password_token;}public function setPasswordToken(?string $password_token): self{$this->password_token = $password_token;return $this;}public function getBirthday(): ?\DateTimeInterface{return $this->birthday;}public function setBirthday(?\DateTimeInterface $birthday): self{$this->birthday = $birthday;return $this;}public function getPhone(): ?string{return $this->phone;}public function setPhone(?string $phone): self{$this->phone = $phone;return $this;}public function getPhoneToken(): ?string{return $this->phone_token;}public function setPhoneToken(?string $phone_token): self{$this->phone_token = $phone_token;return $this;}public function getAvatar(): ?string{if (empty($this->avatar)) {return 'placeholder.png';}return $this->avatar;}public function setAvatar(?string $avatar): self{$this->avatar = $avatar;return $this;}public function getType(): ?string{return $this->type;}public function setType(string $type): self{$this->type = $type;return $this;}public function getStatus(): ?int{return $this->status;}public function setStatus(int $status): self{$this->status = $status;return $this;}public function getRoles(): array{$roles = $this->roles;// guarantee every user at least has ROLE_USER$roles[] = 'ROLE_USER';if($this->getType() == 0)$roles[] = 'ROLE_ADMIN';return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = $roles;return $this;}public function getLang(): ?string{return $this->lang;}public function setLang(?string $lang): self{$this->lang = $lang;return $this;}public function getAddress1(): ?string{return $this->address1;}public function setAddress1(?string $address1): self{$this->address1 = $address1;return $this;}public function getAddress2(): ?string{return $this->address2;}public function setAddress2(?string $address2): self{$this->address2 = $address2;return $this;}public function getZipcode(): ?string{return $this->zipcode;}public function setZipcode(?string $zipcode): self{$this->zipcode = $zipcode;return $this;}public function getCity(): ?string{return $this->city;}public function setCity(?string $city): self{$this->city = $city;return $this;}public function getSocialBrand(): ?string{return $this->social_brand;}public function setSocialBrand(?string $social_brand): self{$this->social_brand = $social_brand;return $this;}public function getSocialId(): ?string{return $this->social_id;}public function setSocialId(string $social_id): self{$this->social_id = $social_id;return $this;}public function getCountry(): ?string{return $this->country;}public function setCountry(?string $country): self{$this->country = $country;return $this;}public function getCreatedAt(): ?\DateTimeInterface{return $this->created_at;}public function setCreatedAt(\DateTimeInterface $created_at): self{$this->created_at = $created_at;return $this;}public function getUpdatedAt(): ?\DateTimeInterface{return $this->updated_at;}public function setUpdatedAt(?\DateTimeInterface $updated_at): self{$this->updated_at = $updated_at;return $this;}public function getLastLogin(): ?\DateTimeInterface{return $this->last_login;}public function setLastLogin(\DateTimeInterface $last_login): self{$this->last_login = $last_login;return $this;}public function eraseCredentials(){// TODO: Implement eraseCredentials() method.}public function getUserIdentifier(): string{return $this->getEmail();}public function getPasswordUpdate(): ?string{return $this->password_update;}public function setPasswordUpdate(?string $password_update): void{$this->password_update = $password_update;}public function isEmailAuthEnabled(): bool{return true; // This can be a persisted field to switch email code authentication on/off}public function getEmailAuthRecipient(): string{return $this->email;}public function getEmailAuthCode(): string{if (null === $this->email_token) {throw new \LogicException('The email authentication code was not set');}return $this->email_token;}public function setEmailAuthCode(string $email_token): void{$this->email_token = $email_token;}public function getTrustedTokenVersion(): int{return $this->trustedVersion;}public function isVerified(): bool{return $this->isVerified;}public function setIsVerified(bool $isVerified): self{$this->isVerified = $isVerified;return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): self{$this->description = $description;return $this;}public function getLocation(): ?string{return $this->location;}public function setLocation(?string $location): self{$this->location = $location;return $this;}/*** @return Collection<int, Media>*/public function getMedias(): Collection{return $this->medias;}public function addMedia(Media $media): self{if (!$this->medias->contains($media)) {$this->medias->add($media);$media->setUser($this);}return $this;}public function removeMedia(Media $media): self{if ($this->medias->removeElement($media)) {// set the owning side to null (unless already changed)if ($media->getUser() === $this) {$media->setUser(null);}}return $this;}/*** @return Collection<int, Price>*/public function getPrices(): Collection{return $this->prices;}public function addPrice(Price $price): self{if (!$this->prices->contains($price)) {$this->prices->add($price);$price->setUser($this);}return $this;}public function removePrice(Price $price): self{if ($this->prices->removeElement($price)) {// set the owning side to null (unless already changed)if ($price->getUser() === $this) {$price->setUser(null);}}return $this;}public function __toString(): string{return $this->fname.' ('.$this->email.')';}/*** @return Collection<int, Service>*/public function getServices(): Collection{return $this->services;}public function addService(Service $service): self{if (!$this->services->contains($service)) {$this->services->add($service);$service->setUser($this);}return $this;}public function removeService(Service $service): self{if ($this->services->removeElement($service)) {// set the owning side to null (unless already changed)if ($service->getUser() === $this) {$service->setUser(null);}}return $this;}/*** @return Collection<int, Reservation>*/public function getReservations(): Collection{return $this->reservations;}public function addReservation(Reservation $reservation): self{if (!$this->reservations->contains($reservation)) {$this->reservations->add($reservation);$reservation->setUser($this);}return $this;}public function removeReservation(Reservation $reservation): self{if ($this->reservations->removeElement($reservation)) {// set the owning side to null (unless already changed)if ($reservation->getUser() === $this) {$reservation->setUser(null);}}return $this;}/*** @return Collection<int, Notification>*/public function getNotifications(): Collection{return $this->notifications;}public function addNotification(Notification $notification): self{if (!$this->notifications->contains($notification)) {$this->notifications->add($notification);$notification->setUser($this);}return $this;}public function removeNotification(Notification $notification): self{if ($this->notifications->removeElement($notification)) {// set the owning side to null (unless already changed)if ($notification->getUser() === $this) {$notification->setUser(null);}}return $this;}/*** @return Collection<int, Favorite>*/public function getFavorites(): Collection{return $this->favorites;}public function addFavorite(Favorite $favorite): self{if (!$this->favorites->contains($favorite)) {$this->favorites->add($favorite);$favorite->setUser($this);}return $this;}public function removeFavorite(Favorite $favorite): self{if ($this->favorites->removeElement($favorite)) {// set the owning side to null (unless already changed)if ($favorite->getUser() === $this) {$favorite->setUser(null);}}return $this;}/*** @return Collection<int, Gallery>*/public function getGalleries(): Collection{return $this->galleries;}public function addGallery(Gallery $gallery): self{if (!$this->galleries->contains($gallery)) {$this->galleries->add($gallery);$gallery->setUser($this);}return $this;}public function removeGallery(Gallery $gallery): self{if ($this->galleries->removeElement($gallery)) {// set the owning side to null (unless already changed)if ($gallery->getUser() === $this) {$gallery->setUser(null);}}return $this;}/*** @return Collection<int, Review>*/public function getReviews(): Collection{return $this->reviews;}public function addReview(Review $review): self{if (!$this->reviews->contains($review)) {$this->reviews->add($review);$review->setUser($this);}return $this;}public function removeReview(Review $review): self{if ($this->reviews->removeElement($review)) {// set the owning side to null (unless already changed)if ($review->getUser() === $this) {$review->setUser(null);}}return $this;}/*** @return Collection<int, Message>*/public function getMessages(): Collection{return $this->messages;}public function addMessage(Message $message): self{if (!$this->messages->contains($message)) {$this->messages->add($message);$message->setSender($this);}return $this;}public function removeMessage(Message $message): self{if ($this->messages->removeElement($message)) {// set the owning side to null (unless already changed)if ($message->getSender() === $this) {$message->setSender(null);}}return $this;}public function getExpoPushToken(): ?string{return $this->expoPushToken;}public function setExpoPushToken(string $expoPushToken): static{$this->expoPushToken = $expoPushToken;return $this;}public function getIdentity(): ?string{return $this->identity;}public function setIdentity(?string $identity): static{$this->identity = $identity;return $this;}}