src/Entity/User.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. /**
  11.  * @ORM\Entity(repositoryClass=UserRepository::class)
  12.  * @ORM\Table(name="`user`")
  13.  * @UniqueEntity(fields={"username"}, message="There is already an account with this username")
  14.  */
  15. class User implements UserInterfacePasswordAuthenticatedUserInterface
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=180, unique=true)
  25.      */
  26.     private $username;
  27.     /**
  28.      * @ORM\Column(type="json")
  29.      */
  30.     private $roles = [];
  31.     /**
  32.      * @var string The hashed password
  33.      * @ORM\Column(type="string")
  34.      */
  35.     private $password;
  36.     /**
  37.      * @ORM\Column(type="boolean")
  38.      */
  39.     private $is_active;
  40.     /**
  41.      * @ORM\Column(type="boolean")
  42.      */
  43.     private $is_locked;
  44.     /**
  45.      * @ORM\Column(type="boolean")
  46.      */
  47.     private $is_company;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private $company_name;
  52.     /**
  53.      * @ORM\Column(type="string", length=255, nullable=true)
  54.      */
  55.     private $vat_id;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $salutation;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      */
  63.     private $first_name;
  64.     /**
  65.      * @ORM\Column(type="string", length=255, nullable=true)
  66.      */
  67.     private $last_name;
  68.     /**
  69.      * @ORM\Column(type="string", length=255, nullable=true)
  70.      */
  71.     private $email;
  72.     /**
  73.      * @ORM\Column(type="string", length=255, nullable=true)
  74.      */
  75.     private $street;
  76.     /**
  77.      * @ORM\Column(type="string", length=255, nullable=true)
  78.      */
  79.     private $street_additional;
  80.     /**
  81.      * @ORM\Column(type="string", length=255, nullable=true)
  82.      */
  83.     private $zip_code;
  84.     /**
  85.      * @ORM\Column(type="string", length=255, nullable=true)
  86.      */
  87.     private $city;
  88.     /**
  89.      * @ORM\Column(type="string", length=255, nullable=true)
  90.      */
  91.     private $country;
  92.     /**
  93.      * @ORM\Column(type="string", length=255, nullable=true)
  94.      */
  95.     private $phone;
  96.     /**
  97.      * @ORM\Column(type="integer", nullable=true)
  98.      */
  99.     private $reg_by;
  100.     /**
  101.      * @ORM\Column(type="datetime", nullable=true)
  102.      */
  103.     private $reg_datetime;
  104.     /**
  105.      * @ORM\OneToMany(targetEntity=Cart::class, mappedBy="client")
  106.      */
  107.     private $carts;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity=Payment::class, mappedBy="client")
  110.      */
  111.     private $payments;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity=Subscription::class, mappedBy="client")
  114.      */
  115.     private $subscriptions;
  116.     /**
  117.      * @ORM\OneToMany(targetEntity=TrialPeriod::class, mappedBy="customer")
  118.      */
  119.     private $trialPeriods;
  120.     /**
  121.      * @ORM\OneToMany(targetEntity=ServiceState::class, mappedBy="client")
  122.      */
  123.     private $serviceStates;
  124.     /**
  125.      * @ORM\Column(type="string", length=255, nullable=true)
  126.      */
  127.     private $company_sid;
  128.     /**
  129.      * @ORM\ManyToOne(targetEntity=Commission::class, inversedBy="users")
  130.      */
  131.     private $commission;
  132.     /**
  133.      * @ORM\OneToMany(targetEntity=Invoice::class, mappedBy="client")
  134.      */
  135.     private $invoices;
  136.     /**
  137.      * @ORM\Column(type="integer", nullable=true)
  138.      */
  139.     private $affiliate_id;
  140.     /**
  141.      * @ORM\OneToMany(targetEntity=SalesCommission::class, mappedBy="sales_person")
  142.      */
  143.     private $salesCommissions;
  144.     /**
  145.      * @ORM\Column(type="string", length=255, nullable=true)
  146.      */
  147.     private $bank_name;
  148.     /**
  149.      * @ORM\Column(type="string", length=255, nullable=true)
  150.      */
  151.     private $bank_account_name;
  152.     /**
  153.      * @ORM\Column(type="string", length=255, nullable=true)
  154.      */
  155.     private $iban;
  156.     /**
  157.      * @ORM\Column(type="string", length=255, nullable=true)
  158.      */
  159.     private $bic;
  160.     /**
  161.      * @ORM\OneToMany(targetEntity=CartWebhosting::class, mappedBy="client")
  162.      */
  163.     private $cartWebhostings;
  164.     /**
  165.      * @ORM\Column(type="boolean", nullable=true)
  166.      */
  167.     private $is_invoiced_by_shop;
  168.     public function __construct()
  169.     {
  170.         $this->carts = new ArrayCollection();
  171.         $this->payments = new ArrayCollection();
  172.         $this->subscriptions = new ArrayCollection();
  173.         $this->trialPeriods = new ArrayCollection();
  174.         $this->serviceStates = new ArrayCollection();
  175.         $this->invoices = new ArrayCollection();
  176.         $this->salesCommissions = new ArrayCollection();
  177.         $this->cartWebhostings = new ArrayCollection();
  178.     }
  179.     public function getId(): ?int
  180.     {
  181.         return $this->id;
  182.     }
  183.     /**
  184.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  185.      */
  186.     public function getUsername(): string
  187.     {
  188.         return (string) $this->username;
  189.     }
  190.     public function setUsername(string $username): self
  191.     {
  192.         $this->username $username;
  193.         return $this;
  194.     }
  195.     /**
  196.      * A visual identifier that represents this user.
  197.      *
  198.      * @see UserInterface
  199.      */
  200.     public function getUserIdentifier(): string
  201.     {
  202.         return (string) $this->username;
  203.     }
  204.     /**
  205.      * @see UserInterface
  206.      */
  207.     public function getRoles(): array
  208.     {
  209.         $roles $this->roles;
  210.         return array_unique($roles);
  211.     }
  212.     public function setRoles(array $roles): self
  213.     {
  214.         $this->roles $roles;
  215.         return $this;
  216.     }
  217.     /**
  218.      * @see PasswordAuthenticatedUserInterface
  219.      */
  220.     public function getPassword(): string
  221.     {
  222.         return $this->password;
  223.     }
  224.     public function setPassword(string $password): self
  225.     {
  226.         $this->password $password;
  227.         return $this;
  228.     }
  229.     /**
  230.      * Returning a salt is only needed, if you are not using a modern
  231.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  232.      *
  233.      * @see UserInterface
  234.      */
  235.     public function getSalt(): ?string
  236.     {
  237.         return null;
  238.     }
  239.     /**
  240.      * @see UserInterface
  241.      */
  242.     public function eraseCredentials()
  243.     {
  244.         // If you store any temporary, sensitive data on the user, clear it here
  245.         // $this->plainPassword = null;
  246.     }
  247.     public function isIsActive(): ?bool
  248.     {
  249.         return $this->is_active;
  250.     }
  251.     public function setIsActive(bool $is_active): self
  252.     {
  253.         $this->is_active $is_active;
  254.         return $this;
  255.     }
  256.     public function isIsLocked(): ?bool
  257.     {
  258.         return $this->is_locked;
  259.     }
  260.     public function setIsLocked(bool $is_locked): self
  261.     {
  262.         $this->is_locked $is_locked;
  263.         return $this;
  264.     }
  265.     public function isIsCompany(): ?bool
  266.     {
  267.         return $this->is_company;
  268.     }
  269.     public function setIsCompany(bool $is_company): self
  270.     {
  271.         $this->is_company $is_company;
  272.         return $this;
  273.     }
  274.     public function getCompanyName(): ?string
  275.     {
  276.         return $this->company_name;
  277.     }
  278.     public function setCompanyName(?string $company_name): self
  279.     {
  280.         $this->company_name $company_name;
  281.         return $this;
  282.     }
  283.     public function getVatId(): ?string
  284.     {
  285.         return $this->vat_id;
  286.     }
  287.     public function setVatId(?string $vat_id): self
  288.     {
  289.         $this->vat_id $vat_id;
  290.         return $this;
  291.     }
  292.     public function getSalutation(): ?string
  293.     {
  294.         return $this->salutation;
  295.     }
  296.     public function setSalutation(?string $salutation): self
  297.     {
  298.         $this->salutation $salutation;
  299.         return $this;
  300.     }
  301.     public function getFirstName(): ?string
  302.     {
  303.         return $this->first_name;
  304.     }
  305.     public function setFirstName(?string $first_name): self
  306.     {
  307.         $this->first_name $first_name;
  308.         return $this;
  309.     }
  310.     public function getLastName(): ?string
  311.     {
  312.         return $this->last_name;
  313.     }
  314.     public function setLastName(?string $last_name): self
  315.     {
  316.         $this->last_name $last_name;
  317.         return $this;
  318.     }
  319.     public function getEmail(): ?string
  320.     {
  321.         return $this->email;
  322.     }
  323.     public function setEmail(?string $email): self
  324.     {
  325.         $this->email $email;
  326.         return $this;
  327.     }
  328.     public function getStreet(): ?string
  329.     {
  330.         return $this->street;
  331.     }
  332.     public function setStreet(?string $street): self
  333.     {
  334.         $this->street $street;
  335.         return $this;
  336.     }
  337.     public function getStreetAdditional(): ?string
  338.     {
  339.         return $this->street_additional;
  340.     }
  341.     public function setStreetAdditional(?string $street_additional): self
  342.     {
  343.         $this->street_additional $street_additional;
  344.         return $this;
  345.     }
  346.     public function getZipCode(): ?string
  347.     {
  348.         return $this->zip_code;
  349.     }
  350.     public function setZipCode(?string $zip_code): self
  351.     {
  352.         $this->zip_code $zip_code;
  353.         return $this;
  354.     }
  355.     public function getCity(): ?string
  356.     {
  357.         return $this->city;
  358.     }
  359.     public function setCity(?string $city): self
  360.     {
  361.         $this->city $city;
  362.         return $this;
  363.     }
  364.     public function getCountry(): ?string
  365.     {
  366.         return $this->country;
  367.     }
  368.     public function setCountry(?string $country): self
  369.     {
  370.         $this->country $country;
  371.         return $this;
  372.     }
  373.     public function getPhone(): ?string
  374.     {
  375.         return $this->phone;
  376.     }
  377.     public function setPhone(?string $phone): self
  378.     {
  379.         $this->phone $phone;
  380.         return $this;
  381.     }
  382.     public function getRegBy(): ?int
  383.     {
  384.         return $this->reg_by;
  385.     }
  386.     public function setRegBy(?int $reg_by): self
  387.     {
  388.         $this->reg_by $reg_by;
  389.         return $this;
  390.     }
  391.     public function getRegDatetime(): ?\DateTimeInterface
  392.     {
  393.         return $this->reg_datetime;
  394.     }
  395.     public function setRegDatetime(?\DateTimeInterface $reg_datetime): self
  396.     {
  397.         $this->reg_datetime $reg_datetime;
  398.         return $this;
  399.     }
  400.     /**
  401.      * @return Collection<int, Cart>
  402.      */
  403.     public function getCarts(): Collection
  404.     {
  405.         return $this->carts;
  406.     }
  407.     public function addCart(Cart $cart): self
  408.     {
  409.         if (!$this->carts->contains($cart)) {
  410.             $this->carts[] = $cart;
  411.             $cart->setClient($this);
  412.         }
  413.         return $this;
  414.     }
  415.     public function removeCart(Cart $cart): self
  416.     {
  417.         if ($this->carts->removeElement($cart)) {
  418.             // set the owning side to null (unless already changed)
  419.             if ($cart->getClient() === $this) {
  420.                 $cart->setClient(null);
  421.             }
  422.         }
  423.         return $this;
  424.     }
  425.     /**
  426.      * @return Collection<int, Payment>
  427.      */
  428.     public function getPayments(): Collection
  429.     {
  430.         return $this->payments;
  431.     }
  432.     public function addPayment(Payment $payment): self
  433.     {
  434.         if (!$this->payments->contains($payment)) {
  435.             $this->payments[] = $payment;
  436.             $payment->setClient($this);
  437.         }
  438.         return $this;
  439.     }
  440.     public function removePayment(Payment $payment): self
  441.     {
  442.         if ($this->payments->removeElement($payment)) {
  443.             // set the owning side to null (unless already changed)
  444.             if ($payment->getClient() === $this) {
  445.                 $payment->setClient(null);
  446.             }
  447.         }
  448.         return $this;
  449.     }
  450.     /**
  451.      * @return Collection<int, Subscription>
  452.      */
  453.     public function getSubscriptions(): Collection
  454.     {
  455.         return $this->subscriptions;
  456.     }
  457.     public function addSubscription(Subscription $subscription): self
  458.     {
  459.         if (!$this->subscriptions->contains($subscription)) {
  460.             $this->subscriptions[] = $subscription;
  461.             $subscription->setClient($this);
  462.         }
  463.         return $this;
  464.     }
  465.     public function removeSubscription(Subscription $subscription): self
  466.     {
  467.         if ($this->subscriptions->removeElement($subscription)) {
  468.             // set the owning side to null (unless already changed)
  469.             if ($subscription->getClient() === $this) {
  470.                 $subscription->setClient(null);
  471.             }
  472.         }
  473.         return $this;
  474.     }
  475.     /**
  476.      * @return Collection<int, TrialPeriod>
  477.      */
  478.     public function getTrialPeriods(): Collection
  479.     {
  480.         return $this->trialPeriods;
  481.     }
  482.     public function addTrialPeriod(TrialPeriod $trialPeriod): self
  483.     {
  484.         if (!$this->trialPeriods->contains($trialPeriod)) {
  485.             $this->trialPeriods[] = $trialPeriod;
  486.             $trialPeriod->setCustomer($this);
  487.         }
  488.         return $this;
  489.     }
  490.     public function removeTrialPeriod(TrialPeriod $trialPeriod): self
  491.     {
  492.         if ($this->trialPeriods->removeElement($trialPeriod)) {
  493.             // set the owning side to null (unless already changed)
  494.             if ($trialPeriod->getCustomer() === $this) {
  495.                 $trialPeriod->setCustomer(null);
  496.             }
  497.         }
  498.         return $this;
  499.     }
  500.     /**
  501.      * @return Collection<int, ServiceState>
  502.      */
  503.     public function getServiceStates(): Collection
  504.     {
  505.         return $this->serviceStates;
  506.     }
  507.     public function addServiceState(ServiceState $serviceState): self
  508.     {
  509.         if (!$this->serviceStates->contains($serviceState)) {
  510.             $this->serviceStates[] = $serviceState;
  511.             $serviceState->setClient($this);
  512.         }
  513.         return $this;
  514.     }
  515.     public function removeServiceState(ServiceState $serviceState): self
  516.     {
  517.         if ($this->serviceStates->removeElement($serviceState)) {
  518.             // set the owning side to null (unless already changed)
  519.             if ($serviceState->getClient() === $this) {
  520.                 $serviceState->setClient(null);
  521.             }
  522.         }
  523.         return $this;
  524.     }
  525.     public function getCompanySid(): ?string
  526.     {
  527.         return $this->company_sid;
  528.     }
  529.     public function setCompanySid(?string $company_sid): self
  530.     {
  531.         $this->company_sid $company_sid;
  532.         return $this;
  533.     }
  534.     public function getCommission(): ?Commission
  535.     {
  536.         return $this->commission;
  537.     }
  538.     public function setCommission(?Commission $commission): self
  539.     {
  540.         $this->commission $commission;
  541.         return $this;
  542.     }
  543.     /**
  544.      * @return Collection<int, Invoice>
  545.      */
  546.     public function getInvoices(): Collection
  547.     {
  548.         return $this->invoices;
  549.     }
  550.     public function addInvoice(Invoice $invoice): self
  551.     {
  552.         if (!$this->invoices->contains($invoice)) {
  553.             $this->invoices[] = $invoice;
  554.             $invoice->setClient($this);
  555.         }
  556.         return $this;
  557.     }
  558.     public function removeInvoice(Invoice $invoice): self
  559.     {
  560.         if ($this->invoices->removeElement($invoice)) {
  561.             // set the owning side to null (unless already changed)
  562.             if ($invoice->getClient() === $this) {
  563.                 $invoice->setClient(null);
  564.             }
  565.         }
  566.         return $this;
  567.     }
  568.     public function getAffiliateId(): ?int
  569.     {
  570.         return $this->affiliate_id;
  571.     }
  572.     public function setAffiliateId(?int $affiliate_id): self
  573.     {
  574.         $this->affiliate_id $affiliate_id;
  575.         return $this;
  576.     }
  577.     /**
  578.      * @return Collection<int, SalesCommission>
  579.      */
  580.     public function getSalesCommissions(): Collection
  581.     {
  582.         return $this->salesCommissions;
  583.     }
  584.     public function addSalesCommission(SalesCommission $salesCommission): self
  585.     {
  586.         if (!$this->salesCommissions->contains($salesCommission)) {
  587.             $this->salesCommissions[] = $salesCommission;
  588.             $salesCommission->setSalesPerson($this);
  589.         }
  590.         return $this;
  591.     }
  592.     public function removeSalesCommission(SalesCommission $salesCommission): self
  593.     {
  594.         if ($this->salesCommissions->removeElement($salesCommission)) {
  595.             // set the owning side to null (unless already changed)
  596.             if ($salesCommission->getSalesPerson() === $this) {
  597.                 $salesCommission->setSalesPerson(null);
  598.             }
  599.         }
  600.         return $this;
  601.     }
  602.     public function __toString()
  603.     {
  604.         return $this->getCompanyName() . ' ' $this->getFirstName() . ' ' $this->getLastName();
  605.     }
  606.     public function getBankName(): ?string
  607.     {
  608.         return $this->bank_name;
  609.     }
  610.     public function setBankName(?string $bank_name): self
  611.     {
  612.         $this->bank_name $bank_name;
  613.         return $this;
  614.     }
  615.     public function getBankAccountName(): ?string
  616.     {
  617.         return $this->bank_account_name;
  618.     }
  619.     public function setBankAccountName(?string $bank_account_name): self
  620.     {
  621.         $this->bank_account_name $bank_account_name;
  622.         return $this;
  623.     }
  624.     public function getIban(): ?string
  625.     {
  626.         return $this->iban;
  627.     }
  628.     public function setIban(?string $iban): self
  629.     {
  630.         $this->iban $iban;
  631.         return $this;
  632.     }
  633.     public function getBic(): ?string
  634.     {
  635.         return $this->bic;
  636.     }
  637.     public function setBic(?string $bic): self
  638.     {
  639.         $this->bic $bic;
  640.         return $this;
  641.     }
  642.     /**
  643.      * @return Collection<int, CartWebhosting>
  644.      */
  645.     public function getCartWebhostings(): Collection
  646.     {
  647.         return $this->cartWebhostings;
  648.     }
  649.     public function addCartWebhosting(CartWebhosting $cartWebhosting): self
  650.     {
  651.         if (!$this->cartWebhostings->contains($cartWebhosting)) {
  652.             $this->cartWebhostings[] = $cartWebhosting;
  653.             $cartWebhosting->setClient($this);
  654.         }
  655.         return $this;
  656.     }
  657.     public function removeCartWebhosting(CartWebhosting $cartWebhosting): self
  658.     {
  659.         if ($this->cartWebhostings->removeElement($cartWebhosting)) {
  660.             // set the owning side to null (unless already changed)
  661.             if ($cartWebhosting->getClient() === $this) {
  662.                 $cartWebhosting->setClient(null);
  663.             }
  664.         }
  665.         return $this;
  666.     }
  667.     public function isIsInvoicedByShop(): ?bool
  668.     {
  669.         return $this->is_invoiced_by_shop;
  670.     }
  671.     public function setIsInvoicedByShop(?bool $is_invoiced_by_shop): self
  672.     {
  673.         $this->is_invoiced_by_shop $is_invoiced_by_shop;
  674.         return $this;
  675.     }
  676. }