<?php
namespace App\Entity;
use App\Repository\RetailUsersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: RetailUsersRepository::class)]
class RetailUsers implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $firstName;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $lastName;
#[ORM\Column(type: 'string', length: 255)]
private $email;
#[ORM\Column(type: 'string', length: 255)]
private $hashedEmail;
#[ORM\Column(type: 'string', length: 255)]
private $password;
#[ORM\Column(type: 'string', length: 255)]
private $telephone;
#[ORM\Column(type: 'string', length: 255)]
private $isoCode;
#[ORM\Column(type: 'string', length: 255)]
private $intlCode;
#[ORM\Column(type: 'json')]
private $roles = [];
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $resetKey;
#[ORM\Column(type: 'datetime')]
private $modified;
#[ORM\Column(type: 'datetime')]
private $created;
#[ORM\OneToMany(targetEntity: Addresses::class, mappedBy: 'retail')]
private $addresses;
#[ORM\OneToMany(targetEntity: ClinicRetailUsers::class, mappedBy: 'retailUser')]
private $clinicRetailUsers;
#[ORM\ManyToOne(targetEntity: Countries::class, inversedBy: 'retailUsers')]
#[ORM\JoinColumn(nullable: false)]
private $country;
#[ORM\OneToMany(targetEntity: Baskets::class, mappedBy: 'retailUser')]
private $baskets;
#[ORM\OneToMany(targetEntity: Orders::class, mappedBy: 'retail')]
private $orders;
#[ORM\Column(type: 'integer', nullable: true)]
private $clinicId;
public function __construct()
{
$this->setModified(new \DateTime());
if ($this->getCreated() == null) {
$this->setCreated(new \DateTime());
}
$this->addresses = new ArrayCollection();
$this->clinicRetailUsers = new ArrayCollection();
$this->baskets = new ArrayCollection();
$this->orders = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getHashedEmail(): ?string
{
return $this->hashedEmail;
}
public function setHashedEmail(string $hashedEmail): self
{
$this->hashedEmail = $hashedEmail;
return $this;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function getIsoCode(): ?string
{
return $this->isoCode;
}
public function setIsoCode(string $isoCode): self
{
$this->isoCode = $isoCode;
return $this;
}
public function getIntlCode(): ?string
{
return $this->intlCode;
}
public function setIntlCode(string $intlCode): self
{
$this->intlCode = $intlCode;
return $this;
}
public function getResetKey(): ?string
{
return $this->resetKey;
}
public function setResetKey(?string $resetKey): self
{
$this->resetKey = $resetKey;
return $this;
}
public function getModified(): ?\DateTimeInterface
{
return $this->modified;
}
public function setModified(\DateTimeInterface $modified): self
{
$this->modified = $modified;
return $this;
}
public function getCreated(): ?\DateTimeInterface
{
return $this->created;
}
public function setCreated(\DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
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 $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 inventory any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection<int, Addresses>
*/
public function getAddresses(): Collection
{
return $this->addresses;
}
public function addAddress(Addresses $address): self
{
if (!$this->addresses->contains($address)) {
$this->addresses[] = $address;
$address->setRetail($this);
}
return $this;
}
public function removeAddress(Addresses $address): self
{
if ($this->addresses->removeElement($address)) {
// set the owning side to null (unless already changed)
if ($address->getRetail() === $this) {
$address->setRetail(null);
}
}
return $this;
}
/**
* @return Collection<int, ClinicRetailUsers>
*/
public function getClinicRetailUsers(): Collection
{
return $this->clinicRetailUsers;
}
public function addClinicRetailUser(ClinicRetailUsers $clinicRetailUser): self
{
if (!$this->clinicRetailUsers->contains($clinicRetailUser)) {
$this->clinicRetailUsers[] = $clinicRetailUser;
$clinicRetailUser->setRetailUser($this);
}
return $this;
}
public function removeClinicRetailUser(ClinicRetailUsers $clinicRetailUser): self
{
if ($this->clinicRetailUsers->removeElement($clinicRetailUser)) {
// set the owning side to null (unless already changed)
if ($clinicRetailUser->getRetailUser() === $this) {
$clinicRetailUser->setRetailUser(null);
}
}
return $this;
}
public function getCountry(): ?Countries
{
return $this->country;
}
public function setCountry(?Countries $country): self
{
$this->country = $country;
return $this;
}
/**
* @return Collection<int, Baskets>
*/
public function getBaskets(): Collection
{
return $this->baskets;
}
public function addBasket(Baskets $basket): self
{
if (!$this->baskets->contains($basket)) {
$this->baskets[] = $basket;
$basket->setRetailUser($this);
}
return $this;
}
public function removeBasket(Baskets $basket): self
{
if ($this->baskets->removeElement($basket)) {
// set the owning side to null (unless already changed)
if ($basket->getRetailUser() === $this) {
$basket->setRetailUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Orders>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Orders $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setRetail($this);
}
return $this;
}
public function removeOrder(Orders $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getRetail() === $this) {
$order->setRetail(null);
}
}
return $this;
}
public function getClinicId(): ?int
{
return $this->clinicId;
}
public function setClinicId(?int $clinicId): self
{
$this->clinicId = $clinicId;
return $this;
}
}