<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
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;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="`user`")
* @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")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\OneToMany(targetEntity=Sales::class, mappedBy="user")
*/
private $sales;
/**
* @ORM\Column(type="string", length=255)
*/
private $fname;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lname;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $username;
/**
* @ORM\ManyToOne(targetEntity=Profile::class, inversedBy="users")
* @ORM\JoinColumn(nullable=false)
*/
private $profile;
/**
* @ORM\Column(type="datetime")
*/
private $creation_date;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $edition_date;
/**
* @ORM\ManyToMany(targetEntity="Shop", fetch="EAGER")
* @ORM\JoinTable(name="user_shop",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="shop_id", referencedColumnName="id")}
* )
*/
private $userShops;
/**
* @ORM\ManyToOne(targetEntity=Shop::class)
*/
private $currentshop;
/**
* @ORM\Column(type="string", length=255)
*/
private $target;
/**
* @ORM\Column(type="boolean")
*/
private $isSynch;
/**
* @ORM\Column(type="boolean")
*/
private $deleted = 0;
public function __construct()
{
$this->sales = new ArrayCollection();
$this->userShops = new ArrayCollection();
}
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 getUserIdentifier(): string
{
return (string) $this->username;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->username;
}
/**
* @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 $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection<int, Sales>
*/
public function getSales(): Collection
{
return $this->sales;
}
public function addSale(Sales $sale): self
{
if (!$this->sales->contains($sale)) {
$this->sales[] = $sale;
$sale->setUser($this);
}
return $this;
}
public function removeSale(Sales $sale): self
{
if ($this->sales->removeElement($sale)) {
// set the owning side to null (unless already changed)
if ($sale->getUser() === $this) {
$sale->setUser(null);
}
}
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 setUsername(?string $username): self
{
$this->username = $username;
return $this;
}
public function getProfile(): ?Profile
{
return $this->profile;
}
public function setProfile(?Profile $profile): self
{
$this->profile = $profile;
return $this;
}
public function getCreationDate(): ?\DateTimeInterface
{
return $this->creation_date;
}
public function setCreationDate(\DateTimeInterface $creation_date): self
{
$this->creation_date = $creation_date;
return $this;
}
public function getEditionDate(): ?\DateTimeInterface
{
return $this->edition_date;
}
public function setEditionDate(?\DateTimeInterface $edition_date): self
{
$this->edition_date = $edition_date;
return $this;
}
/**
* @return Collection<int, UserShop>
*/
public function getUserShops(): Collection
{
return $this->userShops;
}
public function addUserShop(UserShop $userShop): self
{
if (!$this->userShops->contains($userShop)) {
$this->userShops[] = $userShop;
$userShop->setUser($this);
}
return $this;
}
public function removeUserShop(UserShop $userShop): self
{
if ($this->userShops->removeElement($userShop)) {
// set the owning side to null (unless already changed)
if ($userShop->getUser() === $this) {
$userShop->setUser(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getCurrentshop()
{
return $this->currentshop;
}
/**
* @param mixed $currentshop
*/
public function setCurrentshop($currentshop): void
{
$this->currentshop = $currentshop;
}
/**
* @return mixed
*/
public function getTarget()
{
return $this->target;
}
/**
* @param mixed $target
*/
public function setTarget($target): void
{
$this->target = $target;
}
/**
* @return mixed
*/
public function getisSynch()
{
return $this->isSynch;
}
/**
* @param mixed $isSynch
*/
public function setisSynch($isSynch): void
{
$this->isSynch = $isSynch;
}
/**
* @return mixed
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* @param mixed $deleted
*/
public function setDeleted($deleted): void
{
$this->deleted = $deleted;
}
}