<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
* @Groups("user")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
* @Groups("user")
*/
private $username;
/**
* @ORM\Column(type="string", length=180, unique=true)
* @Groups("user")
*/
private $email;
/**
* @var string The hashed password
* @ORM\Column(type="string")
* @Groups("user")
*/
private $password;
/**
* @ORM\Column(type="json")
* @Groups("user")
*/
private $roles = [];
/**
* @ORM\Column(type="string", length=255)
* @Groups("user")
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
* @Groups("user")
*/
private $firstname;
/**
* @ORM\Column(type="date")
*/
private $birthday;
/**
* @ORM\Column(type="text")
*/
private $adress;
/**
* @ORM\Column(type="integer")
*/
private $postalCode;
/**
* @ORM\Column(type="string", length=255)
*/
private $city;
/**
* @ORM\Column(type="string", length=255)
*/
private $country;
/**
* @ORM\Column(type="string", length=255)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255)
* @Groups("user")
*/
private $pseudonym;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\StatutUser", inversedBy="users")
*/
private $statut;
/**
* @ORM\OneToOne(targetEntity="App\Entity\CompagnyInfo", cascade={"persist", "remove"})
*/
private $compagny;
/**
* @ORM\OneToOne(targetEntity="App\Entity\BankInfo", cascade={"persist", "remove"})
*/
private $bank;
/**
* @ORM\OneToOne(targetEntity="App\Entity\ProfilPicture", cascade={"persist", "remove"})
*/
private $profilPicture;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Notation", cascade={"persist", "remove"})
*/
private $notation;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Statistic", cascade={"persist", "remove"})
*/
private $statistic;
/**
* @ORM\OneToMany(targetEntity="App\Entity\GalleryPhoto", mappedBy="userProperty")
*/
private $galleryPhotos;
/**
* @ORM\OneToMany(targetEntity="App\Entity\GalleryVideo", mappedBy="userProperty")
*/
private $galleryVideos;
/**
* @ORM\OneToMany(targetEntity=CommunityPosts::class, mappedBy="userId")
*/
private $communityPosts;
/**
* @ORM\OneToMany(targetEntity=ShoppingCart::class, mappedBy="idUser")
*/
private $shoppingCarts;
/**
* @ORM\OneToMany(targetEntity=Billing::class, mappedBy="idClient")
*/
private $billings;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $registrationDate;
/**
* @ORM\OneToMany(targetEntity=Refund::class, mappedBy="client")
*/
private $refunds;
public function __construct()
{
$this->galleryPhotos = new ArrayCollection();
$this->galleryVideos = new ArrayCollection();
$this->communityPosts = new ArrayCollection();
$this->shoppingCarts = new ArrayCollection();
$this->billings = new ArrayCollection();
$this->refunds = new ArrayCollection();
}
/**
* @param mixed $username
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getBirthday(): ?\DateTimeInterface
{
return $this->birthday;
}
public function setBirthday(\DateTimeInterface $birthday): self
{
$this->birthday = $birthday;
return $this;
}
public function getAdress(): ?string
{
return $this->adress;
}
public function setAdress(string $adress): self
{
$this->adress = $adress;
return $this;
}
public function getPostalCode(): ?int
{
return $this->postalCode;
}
public function setPostalCode(int $postalCode): self
{
$this->postalCode = $postalCode;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getPseudonym(): ?string
{
return $this->pseudonym;
}
public function setPseudonym(string $pseudonym): self
{
$this->pseudonym = $pseudonym;
return $this;
}
public function getStatut(): ?StatutUser
{
return $this->statut;
}
public function setStatut(?StatutUser $statut): self
{
$this->statut = $statut;
return $this;
}
public function getCompagny(): ?CompagnyInfo
{
return $this->compagny;
}
public function setCompagny(?CompagnyInfo $compagny): self
{
$this->compagny = $compagny;
return $this;
}
public function getBank(): ?BankInfo
{
return $this->bank;
}
public function setBank(?BankInfo $bank): self
{
$this->bank = $bank;
return $this;
}
public function getProfilPicture(): ?ProfilPicture
{
return $this->profilPicture;
}
public function setProfilPicture(?ProfilPicture $profilPicture): self
{
$this->profilPicture = $profilPicture;
return $this;
}
public function getNotation(): ?Notation
{
return $this->notation;
}
public function setNotation(?Notation $notation): self
{
$this->notation = $notation;
return $this;
}
public function getStatistic(): ?Statistic
{
return $this->statistic;
}
public function setStatistic(?Statistic $statistic): self
{
$this->statistic = $statistic;
return $this;
}
/**
* @return Collection|GalleryPhoto[]
*/
public function getGalleryPhotos(): Collection
{
return $this->galleryPhotos;
}
public function addGalleryPhoto(GalleryPhoto $galleryPhoto): self
{
if (!$this->galleryPhotos->contains($galleryPhoto)) {
$this->galleryPhotos[] = $galleryPhoto;
$galleryPhoto->setUserProperty($this);
}
return $this;
}
public function removeGalleryPhoto(GalleryPhoto $galleryPhoto): self
{
if ($this->galleryPhotos->contains($galleryPhoto)) {
$this->galleryPhotos->removeElement($galleryPhoto);
// set the owning side to null (unless already changed)
if ($galleryPhoto->getUserProperty() === $this) {
$galleryPhoto->setUserProperty(null);
}
}
return $this;
}
/**
* @return Collection|GalleryVideo[]
*/
public function getGalleryVideos(): Collection
{
return $this->galleryVideos;
}
public function addGalleryVideo(GalleryVideo $galleryVideo): self
{
if (!$this->galleryVideos->contains($galleryVideo)) {
$this->galleryVideos[] = $galleryVideo;
$galleryVideo->setUserProperty($this);
}
return $this;
}
public function removeGalleryVideo(GalleryVideo $galleryVideo): self
{
if ($this->galleryVideos->contains($galleryVideo)) {
$this->galleryVideos->removeElement($galleryVideo);
// set the owning side to null (unless already changed)
if ($galleryVideo->getUserProperty() === $this) {
$galleryVideo->setUserProperty(null);
}
}
return $this;
}
/**
* @return Collection|CommunityPosts[]
*/
public function getCommunityPosts(): Collection
{
return $this->communityPosts;
}
public function addCommunityPost(CommunityPosts $communityPost): self
{
if (!$this->communityPosts->contains($communityPost)) {
$this->communityPosts[] = $communityPost;
$communityPost->setUserId($this);
}
return $this;
}
public function removeCommunityPost(CommunityPosts $communityPost): self
{
if ($this->communityPosts->contains($communityPost)) {
$this->communityPosts->removeElement($communityPost);
// set the owning side to null (unless already changed)
if ($communityPost->getUserId() === $this) {
$communityPost->setUserId(null);
}
}
return $this;
}
/**
* @return Collection|ShoppingCart[]
*/
public function getShoppingCarts(): Collection
{
return $this->shoppingCarts;
}
public function addShoppingCart(ShoppingCart $shoppingCart): self
{
if (!$this->shoppingCarts->contains($shoppingCart)) {
$this->shoppingCarts[] = $shoppingCart;
$shoppingCart->setIdUser($this);
}
return $this;
}
public function removeShoppingCart(ShoppingCart $shoppingCart): self
{
if ($this->shoppingCarts->removeElement($shoppingCart)) {
// set the owning side to null (unless already changed)
if ($shoppingCart->getIdUser() === $this) {
$shoppingCart->setIdUser(null);
}
}
return $this;
}
/**
* @return Collection|Billing[]
*/
public function getBillings(): Collection
{
return $this->billings;
}
public function addBilling(Billing $billing): self
{
if (!$this->billings->contains($billing)) {
$this->billings[] = $billing;
$billing->setIdClient($this);
}
return $this;
}
public function removeBilling(Billing $billing): self
{
if ($this->billings->removeElement($billing)) {
// set the owning side to null (unless already changed)
if ($billing->getIdClient() === $this) {
$billing->setIdClient(null);
}
}
return $this;
}
public function getRegistrationDate(): ?\DateTimeInterface
{
return $this->registrationDate;
}
public function setRegistrationDate(?\DateTimeInterface $registrationDate): self
{
$this->registrationDate = $registrationDate;
return $this;
}
/**
* @return Collection|Refund[]
*/
public function getRefunds(): Collection
{
return $this->refunds;
}
public function addRefund(Refund $refund): self
{
if (!$this->refunds->contains($refund)) {
$this->refunds[] = $refund;
$refund->setClient($this);
}
return $this;
}
public function removeRefund(Refund $refund): self
{
if ($this->refunds->removeElement($refund)) {
// set the owning side to null (unless already changed)
if ($refund->getClient() === $this) {
$refund->setClient(null);
}
}
return $this;
}
public function getUserIdentifier(): string
{
return (string)$this->email;
}
}