<?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={"username"}, message="There is already an account with this username")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $username;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="boolean")
*/
private $is_active;
/**
* @ORM\Column(type="boolean")
*/
private $is_locked;
/**
* @ORM\Column(type="boolean")
*/
private $is_company;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $company_name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $vat_id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $salutation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $first_name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $last_name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $street;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $street_additional;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $zip_code;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $city;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $country;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $reg_by;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $reg_datetime;
/**
* @ORM\OneToMany(targetEntity=Cart::class, mappedBy="client")
*/
private $carts;
/**
* @ORM\OneToMany(targetEntity=Payment::class, mappedBy="client")
*/
private $payments;
/**
* @ORM\OneToMany(targetEntity=Subscription::class, mappedBy="client")
*/
private $subscriptions;
/**
* @ORM\OneToMany(targetEntity=TrialPeriod::class, mappedBy="customer")
*/
private $trialPeriods;
/**
* @ORM\OneToMany(targetEntity=ServiceState::class, mappedBy="client")
*/
private $serviceStates;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $company_sid;
/**
* @ORM\ManyToOne(targetEntity=Commission::class, inversedBy="users")
*/
private $commission;
/**
* @ORM\OneToMany(targetEntity=Invoice::class, mappedBy="client")
*/
private $invoices;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $affiliate_id;
/**
* @ORM\OneToMany(targetEntity=SalesCommission::class, mappedBy="sales_person")
*/
private $salesCommissions;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $bank_name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $bank_account_name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $iban;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $bic;
/**
* @ORM\OneToMany(targetEntity=CartWebhosting::class, mappedBy="client")
*/
private $cartWebhostings;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $is_invoiced_by_shop;
public function __construct()
{
$this->carts = new ArrayCollection();
$this->payments = new ArrayCollection();
$this->subscriptions = new ArrayCollection();
$this->trialPeriods = new ArrayCollection();
$this->serviceStates = new ArrayCollection();
$this->invoices = new ArrayCollection();
$this->salesCommissions = new ArrayCollection();
$this->cartWebhostings = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->username;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
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;
}
public function isIsActive(): ?bool
{
return $this->is_active;
}
public function setIsActive(bool $is_active): self
{
$this->is_active = $is_active;
return $this;
}
public function isIsLocked(): ?bool
{
return $this->is_locked;
}
public function setIsLocked(bool $is_locked): self
{
$this->is_locked = $is_locked;
return $this;
}
public function isIsCompany(): ?bool
{
return $this->is_company;
}
public function setIsCompany(bool $is_company): self
{
$this->is_company = $is_company;
return $this;
}
public function getCompanyName(): ?string
{
return $this->company_name;
}
public function setCompanyName(?string $company_name): self
{
$this->company_name = $company_name;
return $this;
}
public function getVatId(): ?string
{
return $this->vat_id;
}
public function setVatId(?string $vat_id): self
{
$this->vat_id = $vat_id;
return $this;
}
public function getSalutation(): ?string
{
return $this->salutation;
}
public function setSalutation(?string $salutation): self
{
$this->salutation = $salutation;
return $this;
}
public function getFirstName(): ?string
{
return $this->first_name;
}
public function setFirstName(?string $first_name): self
{
$this->first_name = $first_name;
return $this;
}
public function getLastName(): ?string
{
return $this->last_name;
}
public function setLastName(?string $last_name): self
{
$this->last_name = $last_name;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): self
{
$this->street = $street;
return $this;
}
public function getStreetAdditional(): ?string
{
return $this->street_additional;
}
public function setStreetAdditional(?string $street_additional): self
{
$this->street_additional = $street_additional;
return $this;
}
public function getZipCode(): ?string
{
return $this->zip_code;
}
public function setZipCode(?string $zip_code): self
{
$this->zip_code = $zip_code;
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 getRegBy(): ?int
{
return $this->reg_by;
}
public function setRegBy(?int $reg_by): self
{
$this->reg_by = $reg_by;
return $this;
}
public function getRegDatetime(): ?\DateTimeInterface
{
return $this->reg_datetime;
}
public function setRegDatetime(?\DateTimeInterface $reg_datetime): self
{
$this->reg_datetime = $reg_datetime;
return $this;
}
/**
* @return Collection<int, Cart>
*/
public function getCarts(): Collection
{
return $this->carts;
}
public function addCart(Cart $cart): self
{
if (!$this->carts->contains($cart)) {
$this->carts[] = $cart;
$cart->setClient($this);
}
return $this;
}
public function removeCart(Cart $cart): self
{
if ($this->carts->removeElement($cart)) {
// set the owning side to null (unless already changed)
if ($cart->getClient() === $this) {
$cart->setClient(null);
}
}
return $this;
}
/**
* @return Collection<int, Payment>
*/
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): self
{
if (!$this->payments->contains($payment)) {
$this->payments[] = $payment;
$payment->setClient($this);
}
return $this;
}
public function removePayment(Payment $payment): self
{
if ($this->payments->removeElement($payment)) {
// set the owning side to null (unless already changed)
if ($payment->getClient() === $this) {
$payment->setClient(null);
}
}
return $this;
}
/**
* @return Collection<int, Subscription>
*/
public function getSubscriptions(): Collection
{
return $this->subscriptions;
}
public function addSubscription(Subscription $subscription): self
{
if (!$this->subscriptions->contains($subscription)) {
$this->subscriptions[] = $subscription;
$subscription->setClient($this);
}
return $this;
}
public function removeSubscription(Subscription $subscription): self
{
if ($this->subscriptions->removeElement($subscription)) {
// set the owning side to null (unless already changed)
if ($subscription->getClient() === $this) {
$subscription->setClient(null);
}
}
return $this;
}
/**
* @return Collection<int, TrialPeriod>
*/
public function getTrialPeriods(): Collection
{
return $this->trialPeriods;
}
public function addTrialPeriod(TrialPeriod $trialPeriod): self
{
if (!$this->trialPeriods->contains($trialPeriod)) {
$this->trialPeriods[] = $trialPeriod;
$trialPeriod->setCustomer($this);
}
return $this;
}
public function removeTrialPeriod(TrialPeriod $trialPeriod): self
{
if ($this->trialPeriods->removeElement($trialPeriod)) {
// set the owning side to null (unless already changed)
if ($trialPeriod->getCustomer() === $this) {
$trialPeriod->setCustomer(null);
}
}
return $this;
}
/**
* @return Collection<int, ServiceState>
*/
public function getServiceStates(): Collection
{
return $this->serviceStates;
}
public function addServiceState(ServiceState $serviceState): self
{
if (!$this->serviceStates->contains($serviceState)) {
$this->serviceStates[] = $serviceState;
$serviceState->setClient($this);
}
return $this;
}
public function removeServiceState(ServiceState $serviceState): self
{
if ($this->serviceStates->removeElement($serviceState)) {
// set the owning side to null (unless already changed)
if ($serviceState->getClient() === $this) {
$serviceState->setClient(null);
}
}
return $this;
}
public function getCompanySid(): ?string
{
return $this->company_sid;
}
public function setCompanySid(?string $company_sid): self
{
$this->company_sid = $company_sid;
return $this;
}
public function getCommission(): ?Commission
{
return $this->commission;
}
public function setCommission(?Commission $commission): self
{
$this->commission = $commission;
return $this;
}
/**
* @return Collection<int, Invoice>
*/
public function getInvoices(): Collection
{
return $this->invoices;
}
public function addInvoice(Invoice $invoice): self
{
if (!$this->invoices->contains($invoice)) {
$this->invoices[] = $invoice;
$invoice->setClient($this);
}
return $this;
}
public function removeInvoice(Invoice $invoice): self
{
if ($this->invoices->removeElement($invoice)) {
// set the owning side to null (unless already changed)
if ($invoice->getClient() === $this) {
$invoice->setClient(null);
}
}
return $this;
}
public function getAffiliateId(): ?int
{
return $this->affiliate_id;
}
public function setAffiliateId(?int $affiliate_id): self
{
$this->affiliate_id = $affiliate_id;
return $this;
}
/**
* @return Collection<int, SalesCommission>
*/
public function getSalesCommissions(): Collection
{
return $this->salesCommissions;
}
public function addSalesCommission(SalesCommission $salesCommission): self
{
if (!$this->salesCommissions->contains($salesCommission)) {
$this->salesCommissions[] = $salesCommission;
$salesCommission->setSalesPerson($this);
}
return $this;
}
public function removeSalesCommission(SalesCommission $salesCommission): self
{
if ($this->salesCommissions->removeElement($salesCommission)) {
// set the owning side to null (unless already changed)
if ($salesCommission->getSalesPerson() === $this) {
$salesCommission->setSalesPerson(null);
}
}
return $this;
}
public function __toString()
{
return $this->getCompanyName() . ' ' . $this->getFirstName() . ' ' . $this->getLastName();
}
public function getBankName(): ?string
{
return $this->bank_name;
}
public function setBankName(?string $bank_name): self
{
$this->bank_name = $bank_name;
return $this;
}
public function getBankAccountName(): ?string
{
return $this->bank_account_name;
}
public function setBankAccountName(?string $bank_account_name): self
{
$this->bank_account_name = $bank_account_name;
return $this;
}
public function getIban(): ?string
{
return $this->iban;
}
public function setIban(?string $iban): self
{
$this->iban = $iban;
return $this;
}
public function getBic(): ?string
{
return $this->bic;
}
public function setBic(?string $bic): self
{
$this->bic = $bic;
return $this;
}
/**
* @return Collection<int, CartWebhosting>
*/
public function getCartWebhostings(): Collection
{
return $this->cartWebhostings;
}
public function addCartWebhosting(CartWebhosting $cartWebhosting): self
{
if (!$this->cartWebhostings->contains($cartWebhosting)) {
$this->cartWebhostings[] = $cartWebhosting;
$cartWebhosting->setClient($this);
}
return $this;
}
public function removeCartWebhosting(CartWebhosting $cartWebhosting): self
{
if ($this->cartWebhostings->removeElement($cartWebhosting)) {
// set the owning side to null (unless already changed)
if ($cartWebhosting->getClient() === $this) {
$cartWebhosting->setClient(null);
}
}
return $this;
}
public function isIsInvoicedByShop(): ?bool
{
return $this->is_invoiced_by_shop;
}
public function setIsInvoicedByShop(?bool $is_invoiced_by_shop): self
{
$this->is_invoiced_by_shop = $is_invoiced_by_shop;
return $this;
}
}