src/Flexy/ShopBundle/Entity/Customer/Customer.php line 42

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Customer;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  7. use App\Entity\User;
  8. use App\Flexy\ShopBundle\Entity\Accounting\Invoice;
  9. use App\Flexy\ShopBundle\Entity\Order\Order;
  10. use App\Flexy\ShopBundle\Entity\Payment\BankBookItem;
  11. use App\Flexy\ShopBundle\Entity\Product\Comment;
  12. use App\Flexy\ShopBundle\Entity\Product\ProductSubscription;
  13. use App\Flexy\ShopBundle\Entity\Promotion\Coupon;
  14. use App\Flexy\ShopBundle\Entity\Shipping\CashOnDelivery;
  15. use App\Flexy\ShopBundle\Entity\Shipping\CityRegion;
  16. use App\Flexy\ShopBundle\Entity\Shipping\Shipment;
  17. use App\Flexy\ShopBundle\Entity\Store\Store;
  18. use App\Flexy\ShopBundle\Entity\Vendor\Vendor;
  19. use App\Flexy\ShopBundle\Repository\Customer\CustomerRepository;
  20. use Doctrine\Common\Collections\ArrayCollection;
  21. use Doctrine\Common\Collections\Collection;
  22. use Doctrine\ORM\Mapping as ORM;
  23. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  24. use Symfony\Component\Serializer\Annotation\Groups;
  25. use Symfony\Component\Validator\Constraints as Assert;
  26. use Gedmo\Mapping\Annotation as Gedmo;
  27. //use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  28. #[ApiResource(
  29.     normalizationContext: ['groups' => ['read','readPackEngagements']],
  30.     denormalizationContext: ['groups' => ['write']],
  31. )]
  32. #[ApiFilter(SearchFilter::class, properties: ['user.googleId' => 'exact','user.facebookId' => 'exact','firstName'=>'partial','lastName'=>'partial','phone'=>'partial'])]
  33. #[ApiFilter(OrderFilter::class, properties: ['firstName' => 'DESC'])]
  34. #[ORM\Entity(repositoryClassCustomerRepository::class)]
  35. #[UniqueEntity(fields: ['email'], message'This email is already in use.')]
  36. #[UniqueEntity(fields: ['phone'], message'This phone number is already in use.',groups:["create"])]
  37. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  38. class Customer implements \Stringable
  39. {
  40.     #[ORM\Id]
  41.     #[ORM\GeneratedValue]
  42.     #[ORM\Column(type'integer')]
  43.     #[Groups(["read","write"])]
  44.     private $id;
  45.     #[ORM\Column(type'text'nullabletrue)]
  46.     private ?string $description null;
  47.     #[Groups(["read","write"])]
  48.     #[ORM\Column(type'string'length255nullablefalseuniquetrue)]
  49.     #[Assert\Email]
  50.     #[Assert\NotNull]
  51.     #[Assert\NotBlank]
  52.     private ?string $email null;
  53.     #[ORM\Column(type'datetime'nullabletrue)]
  54.     private ?\DateTime $createdAt null;
  55.     #[Groups(["read","write"])]
  56.     #[ORM\Column(type'string'length255)]
  57.     private ?string $firstName null;
  58.     #[Groups(["read","write"])]
  59.     #[ORM\Column(type'string'length255)]
  60.     private ?string $lastName null;
  61.     #[Groups(["read","write"])]
  62.     #[ORM\Column(type'string'length255nullabletrue)]
  63.     private ?string $address null;
  64.     #[Groups(["read","write"])]
  65.     #[ORM\Column(type'string'length255nullabletrue)]
  66.     private $city;
  67.     #[Groups(["read","write"])]
  68.     #[ORM\Column(type'string'length255)]
  69.     #[Assert\Length(min8)]
  70.     private ?string $phone null;
  71.     #[Groups(["read","write"])]
  72.     #[ORM\Column(type'string'length255nullabletrue)]
  73.     private ?string $companyName null;
  74.     #[Groups(["read","write"])]
  75.     #[ORM\Column(type'string'length255nullabletrue)]
  76.     private ?string $addressIndication null;
  77.     #[Groups(["read","write"])]
  78.     #[ORM\Column(type'string'length255nullabletrue)]
  79.     private ?string $country null;
  80.     #[Groups(["read","write"])]
  81.     #[ORM\Column(type'string'length255nullabletrue)]
  82.     private ?string $postCode null;
  83.     
  84.     #[ORM\OneToMany(targetEntityOrder::class, mappedBy'customer'orphanRemovaltruecascade: ['persist''remove'])]
  85.     private \Doctrine\Common\Collections\Collection|array $orders;
  86.     #[Groups(["read","write"])]
  87.     #[ORM\ManyToOne(targetEntityCustomerGroup::class, inversedBy'customers'cascade: ['persist'])]
  88.     private ?\App\Flexy\ShopBundle\Entity\Customer\CustomerGroup $customerGroup null;
  89.     #[Groups(["read","write"])]
  90.     #[ORM\OneToOne(targetEntityUser::class, orphanRemovaltruecascade: ['persist''remove'])]
  91.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  92.     private ?\App\Entity\User $user null;
  93.     #[ORM\OneToMany(targetEntityComment::class, mappedBy'customer')]
  94.     private \Doctrine\Common\Collections\Collection|array $comments;
  95.     #[Groups(["read","write"])]
  96.     #[ORM\Column(type'string'length255nullabletrue)]
  97.     private ?string $gender null;
  98.     #[Groups(["read","write"])]
  99.     #[ORM\Column(type'date'nullabletrue)]
  100.     private ?\DateTimeInterface $dateOfBirth null;
  101.     #[ORM\OneToMany(targetEntityCustomerAddress::class, mappedBy'customer'cascade: ['persist''remove'])]
  102.     private \Doctrine\Common\Collections\Collection|array $customerAddresses;
  103.     #[ORM\OneToMany(targetEntityCustomerWalletPoint::class, mappedBy'customer'orphanRemovaltruecascade: ['persist''remove'])]
  104.     private \Doctrine\Common\Collections\Collection|array $customerWalletPoints;
  105.     #[ORM\ManyToOne(targetEntityVendor::class, inversedBy'customers')]
  106.     private ?\App\Flexy\ShopBundle\Entity\Vendor\Vendor $vendor null;
  107.     #[ORM\ManyToOne(targetEntityCityRegion::class)]
  108.     #[Groups(["read","write"])]
  109.     private $cityRegion;
  110.     #[ORM\OneToMany(targetEntityPackEngagement::class, mappedBy'customer'cascade: ['remove'], orphanRemovaltrue)]
  111.     private \Doctrine\Common\Collections\Collection|array $packEngagements;
  112.     #[Groups(["read","write"])]
  113.     #[ORM\Column(type'string'length255nullabletrue)]
  114.     private ?string $sponsorshipCode null;
  115.     #[Groups(["read","write"])]
  116.     #[ORM\Column(type'string'length255nullabletrue)]
  117.     private ?string $image null;
  118.     #[ORM\ManyToMany(targetEntityCoupon::class, mappedBy'allowedCustomers')]
  119.     private \Doctrine\Common\Collections\Collection|array $affectedCoupons;
  120.     #[ORM\OneToMany(targetEntityCoupon::class, mappedBy'onlyThisCustomer')]
  121.     private \Doctrine\Common\Collections\Collection|array $affectedCouponsOnlyForMe;
  122.         #[Groups(["read","write"])]
  123.     #[ORM\Column(type'boolean'nullabletrue)]
  124.     private $canReceiveMails;
  125.     #[Groups(["read","write"])]
  126.     #[ORM\Column(type'boolean'nullabletrue)]
  127.     private $canReceiveSms;
  128.     #[ORM\Column(type'string'length255nullabletrue)]
  129.     private $blindPassword;
  130.     #[ORM\Column(nullabletrue)]
  131.     private ?\DateTimeImmutable $deletedAt null;
  132.     #[ORM\OneToMany(mappedBy'senderCustomer'targetEntityShipment::class)]
  133.     private Collection $sentShipments;
  134.     #[ORM\OneToMany(mappedBy'recipientCustomer'targetEntityShipment::class)]
  135.     private Collection $receivedShipments;
  136.     #[ORM\OneToMany(mappedBy'customer'targetEntityBankBookItem::class)]
  137.     private Collection $bankBookItems;
  138.     #[ORM\OneToMany(mappedBy'customer'targetEntityCashOnDelivery::class)]
  139.     private Collection $cashOnDeliveries;
  140.     #[ORM\OneToMany(mappedBy'customer'targetEntityProductSubscription::class)]
  141.     #[Groups(["read","write"])]
  142.     private Collection $productSubscriptions;
  143.     #[Groups(["read","write"])]
  144.     #[ORM\ManyToOne(inversedBy'customers')]
  145.     private ?Store $store null;
  146.     // Undefined array key \"invoice\"" To be fixed for #[Groups(['read','write'])]
  147.     #[ORM\OneToMany(mappedBy'customer'targetEntityInvoice::class)]
  148.     private Collection $invoices;
  149.     #[ORM\Column(length255nullabletrue)]
  150.     #[Groups(["read","write"])]
  151.     private ?string $collectAddress null;
  152.     #[ORM\Column(length255nullabletrue)]
  153.     #[Groups(["read","write"])]
  154.     private ?string $shippingAddress null;
  155.     #[ORM\Column(length255nullabletrue)]
  156.     #[Groups(["read","write"])]
  157.     private ?string $collectLat null;
  158.     #[ORM\Column(length255nullabletrue)]
  159.     #[Groups(["read","write"])]
  160.     private ?string $collectLng null;
  161.     #[ORM\Column(length255nullabletrue)]
  162.     #[Groups(["read","write"])]
  163.     private ?string $shippingLng null;
  164.     #[ORM\OneToMany(mappedBy'customer'targetEntityComplaint::class)]
  165.     #[Groups(["read","write"])]
  166.     private Collection $complaints;
  167.     #[ORM\Column(nullabletrue)]
  168.     private ?array $metaData null;
  169.    
  170.     public function __construct()
  171.     {
  172.         $this->sentShipments = new ArrayCollection();
  173.         $this->receivedShipments = new ArrayCollection();
  174.         $this->bankBookItems = new ArrayCollection();
  175.         $this->cashOnDeliveries = new ArrayCollection();
  176.         $this->productSubscriptions = new ArrayCollection();
  177.         $this->invoices = new ArrayCollection();
  178.         $this->customerWalletPoints = new ArrayCollection();
  179.         $this->createdAt = new \DateTime();
  180.         $this->complaints = new ArrayCollection();
  181.     }
  182.     public function __toString(): string
  183.     {
  184.         return $this->firstName." ".$this->lastName;
  185.     }
  186.     public function getId(): ?int
  187.     {
  188.         return $this->id;
  189.     }
  190.     public function getDescription(): ?string
  191.     {
  192.         return $this->description;
  193.     }
  194.     public function setDescription(?string $description): self
  195.     {
  196.         $this->description $description;
  197.         return $this;
  198.     }
  199.     public function getEmail(): ?string
  200.     {
  201.         return $this->email;
  202.     }
  203.     public function setEmail(?string $email): self
  204.     {
  205.         $this->email $email;
  206.         return $this;
  207.     }
  208.     public function getCreatedAt(): ?\DateTime
  209.     {
  210.         return $this->createdAt;
  211.     }
  212.     public function setCreatedAt(?\DateTime $createdAt): self
  213.     {
  214.         $this->createdAt $createdAt;
  215.         return $this;
  216.     }
  217.     public function getFirstName(): ?string
  218.     {
  219.         return $this->firstName;
  220.     }
  221.     public function setFirstName(string $firstName): self
  222.     {
  223.         $this->firstName $firstName;
  224.         return $this;
  225.     }
  226.     public function getLastName(): ?string
  227.     {
  228.         return $this->lastName;
  229.     }
  230.     public function setLastName(string $lastName): self
  231.     {
  232.         $this->lastName $lastName;
  233.         return $this;
  234.     }
  235.     public function getAddress(): ?string
  236.     {
  237.         return $this->address;
  238.     }
  239.     public function setAddress(?string $address): self
  240.     {
  241.         $this->address $address;
  242.         return $this;
  243.     }
  244.     public function getPhone(): ?string
  245.     {
  246.         return $this->phone;
  247.     }
  248.     public function setPhone(string $phone): self
  249.     {
  250.         $this->phone $phone;
  251.         return $this;
  252.     }
  253.     public function getCompanyName(): ?string
  254.     {
  255.         return $this->companyName;
  256.     }
  257.     public function setCompanyName(?string $companyName): self
  258.     {
  259.         $this->companyName $companyName;
  260.         return $this;
  261.     }
  262.     public function getAddressIndication(): ?string
  263.     {
  264.         return $this->addressIndication;
  265.     }
  266.     public function setAddressIndication(?string $addressIndication): self
  267.     {
  268.         $this->addressIndication $addressIndication;
  269.         return $this;
  270.     }
  271.     public function getCountry(): ?string
  272.     {
  273.         return $this->country;
  274.     }
  275.     public function setCountry(?string $country): self
  276.     {
  277.         $this->country $country;
  278.         return $this;
  279.     }
  280.     public function getPostCode(): ?string
  281.     {
  282.         return $this->postCode;
  283.     }
  284.     public function setPostCode(string $postCode): self
  285.     {
  286.         $this->postCode $postCode;
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return Collection|Order[]
  291.      */
  292.     public function getOrders(): Collection
  293.     {
  294.         return $this->orders;
  295.     }
  296.     public function addOrder(Order $order): self
  297.     {
  298.         if (!$this->orders->contains($order)) {
  299.             $this->orders[] = $order;
  300.             $order->setCustomer($this);
  301.         }
  302.         return $this;
  303.     }
  304.     public function removeOrder(Order $order): self
  305.     {
  306.         if ($this->orders->removeElement($order)) {
  307.             // set the owning side to null (unless already changed)
  308.             if ($order->getCustomer() === $this) {
  309.                 $order->setCustomer(null);
  310.             }
  311.         }
  312.         return $this;
  313.     }
  314.     public function getCustomerGroup(): ?CustomerGroup
  315.     {
  316.         return $this->customerGroup;
  317.     }
  318.     public function setCustomerGroup(?CustomerGroup $customerGroup): self
  319.     {
  320.         $this->customerGroup $customerGroup;
  321.         return $this;
  322.     }
  323.     public function getUser(): ?User
  324.     {
  325.         return $this->user;
  326.     }
  327.     public function setUser(?User $user): self
  328.     {
  329.         $this->user $user;
  330.         return $this;
  331.     }
  332.     /**
  333.      * @return Collection|Comment[]
  334.      */
  335.     public function getComments(): Collection
  336.     {
  337.         return $this->comments;
  338.     }
  339.     public function addComment(Comment $comment): self
  340.     {
  341.         if (!$this->comments->contains($comment)) {
  342.             $this->comments[] = $comment;
  343.             $comment->setCustomer($this);
  344.         }
  345.         return $this;
  346.     }
  347.     public function removeComment(Comment $comment): self
  348.     {
  349.         if ($this->comments->removeElement($comment)) {
  350.             // set the owning side to null (unless already changed)
  351.             if ($comment->getCustomer() === $this) {
  352.                 $comment->setCustomer(null);
  353.             }
  354.         }
  355.         return $this;
  356.     }
  357.     public function getGender(): ?string
  358.     {
  359.         return $this->gender;
  360.     }
  361.     public function setGender(?string $gender): self
  362.     {
  363.         $this->gender $gender;
  364.         return $this;
  365.     }
  366.     public function getDateOfBirth(): ?\DateTimeInterface
  367.     {
  368.         return $this->dateOfBirth;
  369.     }
  370.     public function setDateOfBirth(?\DateTimeInterface $dateOfBirth): self
  371.     {
  372.         $this->dateOfBirth $dateOfBirth;
  373.         return $this;
  374.     }
  375.     /**
  376.      * @return Collection<int, CustomerAddress>
  377.      */
  378.     public function getCustomerAddresses(): Collection
  379.     {
  380.         return $this->customerAddresses;
  381.     }
  382.     public function addCustomerAddress(CustomerAddress $customerAddress): self
  383.     {
  384.         if (!$this->customerAddresses->contains($customerAddress)) {
  385.             $this->customerAddresses[] = $customerAddress;
  386.             $customerAddress->setCustomer($this);
  387.         }
  388.         return $this;
  389.     }
  390.     public function removeCustomerAddress(CustomerAddress $customerAddress): self
  391.     {
  392.         if ($this->customerAddresses->removeElement($customerAddress)) {
  393.             // set the owning side to null (unless already changed)
  394.             if ($customerAddress->getCustomer() === $this) {
  395.                 $customerAddress->setCustomer(null);
  396.             }
  397.         }
  398.         return $this;
  399.     }
  400.     /**
  401.      * @return Collection<int, CustomerWalletPoint>
  402.      */
  403.     public function getCustomerWalletPoints(): Collection
  404.     {
  405.         return $this->customerWalletPoints;
  406.     }
  407.     public function addCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self
  408.     {
  409.         if (!$this->customerWalletPoints->contains($customerWalletPoint)) {
  410.             $this->customerWalletPoints[] = $customerWalletPoint;
  411.             $customerWalletPoint->setCustomer($this);
  412.         }
  413.         return $this;
  414.     }
  415.     public function removeCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self
  416.     {
  417.         if ($this->customerWalletPoints->removeElement($customerWalletPoint)) {
  418.             // set the owning side to null (unless already changed)
  419.             if ($customerWalletPoint->getCustomer() === $this) {
  420.                 $customerWalletPoint->setCustomer(null);
  421.             }
  422.         }
  423.         return $this;
  424.     }
  425.     #[Groups(["read","write"])]
  426.     public function getCredit(){
  427.         $credit 0;
  428.         foreach($this->getCustomerWalletPoints() as $singleWalletPoint){
  429.             if($singleWalletPoint->getOriginInvoice()){
  430.                 if($singleWalletPoint->getOriginInvoice()->getStatus() != "draft"){
  431.                     $credit $credit $singleWalletPoint->getPoints();
  432.                 }
  433.             }
  434.             
  435.             
  436.         }
  437.         return $credit;
  438.     }
  439.     #[Groups(["read","write"])]
  440.     public function getWalletCredit(){
  441.         $credit 0;
  442.         foreach($this->getCustomerWalletPoints() as $singleWalletPoint){
  443.             
  444.                     
  445.                     $credit $credit $singleWalletPoint->getPoints();
  446.                 
  447.             
  448.             
  449.             
  450.         }
  451.         return $credit;
  452.     }
  453.     public function getVendor(): ?Vendor
  454.     {
  455.         return $this->vendor;
  456.     }
  457.     public function setVendor(?Vendor $vendor): self
  458.     {
  459.         $this->vendor $vendor;
  460.         return $this;
  461.     }
  462.     /**
  463.      * @return Collection<int, PackEngagement>
  464.      */
  465.     public function getPackEngagements(): Collection
  466.     {
  467.         return $this->packEngagements;
  468.     }
  469.     public function addPackEngagement(PackEngagement $packEngagement): self
  470.     {
  471.         if (!$this->packEngagements->contains($packEngagement)) {
  472.             $this->packEngagements[] = $packEngagement;
  473.             $packEngagement->setCustomer($this);
  474.         }
  475.         return $this;
  476.     }
  477.     public function removePackEngagement(PackEngagement $packEngagement): self
  478.     {
  479.         if ($this->packEngagements->removeElement($packEngagement)) {
  480.             // set the owning side to null (unless already changed)
  481.             if ($packEngagement->getCustomer() === $this) {
  482.                 $packEngagement->setCustomer(null);
  483.             }
  484.         }
  485.         return $this;
  486.     }
  487.     public function getSponsorshipCode(): ?string
  488.     {
  489.         return $this->sponsorshipCode;
  490.     }
  491.     public function setSponsorshipCode(?string $sponsorshipCode): self
  492.     {
  493.         $this->sponsorshipCode $sponsorshipCode;
  494.         return $this;
  495.     }
  496.     public function getMySponsorshipCode(){
  497.         return "PRN0000".$this->getId();
  498.     }
  499.     public function getImage(): ?string
  500.     {
  501.         return $this->image;
  502.     }
  503.     public function setImage(?string $image): self
  504.     {
  505.         $this->image $image;
  506.         return $this;
  507.     }
  508.     /**
  509.      * @return Collection<int, Coupon>
  510.      */
  511.     public function getAffectedCoupons(): Collection
  512.     {
  513.         return $this->affectedCoupons;
  514.     }
  515.     public function addAffectedCoupon(Coupon $affectedCoupon): self
  516.     {
  517.         if (!$this->affectedCoupons->contains($affectedCoupon)) {
  518.             $this->affectedCoupons[] = $affectedCoupon;
  519.             $affectedCoupon->addAllowedCustomer($this);
  520.         }
  521.         return $this;
  522.     }
  523.     public function removeAffectedCoupon(Coupon $affectedCoupon): self
  524.     {
  525.         if ($this->affectedCoupons->removeElement($affectedCoupon)) {
  526.             $affectedCoupon->removeAllowedCustomer($this);
  527.         }
  528.         return $this;
  529.     }
  530.     /**
  531.      * @return Collection<int, Coupon>
  532.      */
  533.     public function getAffectedCouponsOnlyForMe(): Collection
  534.     {
  535.         return $this->affectedCouponsOnlyForMe;
  536.     }
  537.     public function addAffectedCouponsOnlyForMe(Coupon $affectedCouponsOnlyForMe): self
  538.     {
  539.         if (!$this->affectedCouponsOnlyForMe->contains($affectedCouponsOnlyForMe)) {
  540.             $this->affectedCouponsOnlyForMe[] = $affectedCouponsOnlyForMe;
  541.             $affectedCouponsOnlyForMe->setOnlyThisCustomer($this);
  542.         }
  543.         return $this;
  544.     }
  545.     public function removeAffectedCouponsOnlyForMe(Coupon $affectedCouponsOnlyForMe): self
  546.     {
  547.         if ($this->affectedCouponsOnlyForMe->removeElement($affectedCouponsOnlyForMe)) {
  548.             // set the owning side to null (unless already changed)
  549.             if ($affectedCouponsOnlyForMe->getOnlyThisCustomer() === $this) {
  550.                 $affectedCouponsOnlyForMe->setOnlyThisCustomer(null);
  551.             }
  552.         }
  553.         return $this;
  554.     }
  555.     
  556.      
  557.     /**
  558.      * Get the value of canReceiveMails
  559.      */ 
  560.     public function getCanReceiveMails()
  561.     {
  562.         return $this->canReceiveMails;
  563.     }
  564.     /**
  565.      * Set the value of canReceiveMails
  566.      *
  567.      * @return  self
  568.      */ 
  569.     public function setCanReceiveMails($canReceiveMails)
  570.     {
  571.         $this->canReceiveMails $canReceiveMails;
  572.         return $this;
  573.     }
  574.     /**
  575.      * Get the value of canReceiveSms
  576.      */ 
  577.     public function getCanReceiveSms()
  578.     {
  579.         return $this->canReceiveSms;
  580.     }
  581.     /**
  582.      * Set the value of canReceiveSms
  583.      *
  584.      * @return  self
  585.      */ 
  586.     public function setCanReceiveSms($canReceiveSms)
  587.     {
  588.         $this->canReceiveSms $canReceiveSms;
  589.         return $this;
  590.     }
  591.     /**
  592.      * Get the value of blindPassword
  593.      */ 
  594.     public function getBlindPassword()
  595.     {
  596.         return $this->blindPassword;
  597.     }
  598.     /**
  599.      * Set the value of blindPassword
  600.      *
  601.      * @return  self
  602.      */ 
  603.     public function setBlindPassword($blindPassword)
  604.     {
  605.         $this->blindPassword $blindPassword;
  606.         return $this;
  607.     }
  608.     /**
  609.      * Get the value of city
  610.      */ 
  611.     public function getCity()
  612.     {
  613.         return $this->city;
  614.     }
  615.     /**
  616.      * Set the value of city
  617.      *
  618.      * @return  self
  619.      */ 
  620.     public function setCity($city)
  621.     {
  622.         $this->city $city;
  623.         return $this;
  624.     }
  625.     /**
  626.      * Get the value of cityRegion
  627.      */ 
  628.     public function getCityRegion()
  629.     {
  630.         return $this->cityRegion;
  631.     }
  632.     /**
  633.      * Set the value of cityRegion
  634.      *
  635.      * @return  self
  636.      */ 
  637.     public function setCityRegion($cityRegion)
  638.     {
  639.         $this->cityRegion $cityRegion;
  640.         return $this;
  641.     }
  642.     public function getDeletedAt(): ?\DateTimeImmutable
  643.     {
  644.         return $this->deletedAt;
  645.     }
  646.     public function setDeletedAt(?\DateTimeImmutable $deletedAt): self
  647.     {
  648.         $this->deletedAt $deletedAt;
  649.         return $this;
  650.     }
  651.     /**
  652.      * @return Collection<int, Shipment>
  653.      */
  654.     public function getSentShipments(): Collection
  655.     {
  656.         return $this->sentShipments;
  657.     }
  658.     public function addSentShipment(Shipment $sentShipment): self
  659.     {
  660.         if (!$this->sentShipments->contains($sentShipment)) {
  661.             $this->sentShipments->add($sentShipment);
  662.             $sentShipment->setSenderCustomer($this);
  663.         }
  664.         return $this;
  665.     }
  666.     public function removeSentShipment(Shipment $sentShipment): self
  667.     {
  668.         if ($this->sentShipments->removeElement($sentShipment)) {
  669.             // set the owning side to null (unless already changed)
  670.             if ($sentShipment->getSenderCustomer() === $this) {
  671.                 $sentShipment->setSenderCustomer(null);
  672.             }
  673.         }
  674.         return $this;
  675.     }
  676.     /**
  677.      * @return Collection<int, Shipment>
  678.      */
  679.     public function getReceivedShipments(): Collection
  680.     {
  681.         return $this->receivedShipments;
  682.     }
  683.     public function addReceivedShipment(Shipment $receivedShipment): self
  684.     {
  685.         if (!$this->receivedShipments->contains($receivedShipment)) {
  686.             $this->receivedShipments->add($receivedShipment);
  687.             $receivedShipment->setRecipientCustomer($this);
  688.         }
  689.         return $this;
  690.     }
  691.     public function removeReceivedShipment(Shipment $receivedShipment): self
  692.     {
  693.         if ($this->receivedShipments->removeElement($receivedShipment)) {
  694.             // set the owning side to null (unless already changed)
  695.             if ($receivedShipment->getRecipientCustomer() === $this) {
  696.                 $receivedShipment->setRecipientCustomer(null);
  697.             }
  698.         }
  699.         return $this;
  700.     }
  701.     /**
  702.      * @return Collection<int, BankBookItem>
  703.      */
  704.     public function getBankBookItems(): Collection
  705.     {
  706.         return $this->bankBookItems;
  707.     }
  708.     public function addBankBookItem(BankBookItem $bankBookItem): self
  709.     {
  710.         if (!$this->bankBookItems->contains($bankBookItem)) {
  711.             $this->bankBookItems->add($bankBookItem);
  712.             $bankBookItem->setCustomer($this);
  713.         }
  714.         return $this;
  715.     }
  716.     public function removeBankBookItem(BankBookItem $bankBookItem): self
  717.     {
  718.         if ($this->bankBookItems->removeElement($bankBookItem)) {
  719.             // set the owning side to null (unless already changed)
  720.             if ($bankBookItem->getCustomer() === $this) {
  721.                 $bankBookItem->setCustomer(null);
  722.             }
  723.         }
  724.         return $this;
  725.     }
  726.     /**
  727.      * @return Collection<int, CashOnDelivery>
  728.      */
  729.     public function getCashOnDeliveries(): Collection
  730.     {
  731.         return $this->cashOnDeliveries;
  732.     }
  733.     public function addCashOnDelivery(CashOnDelivery $cashOnDelivery): self
  734.     {
  735.         if (!$this->cashOnDeliveries->contains($cashOnDelivery)) {
  736.             $this->cashOnDeliveries->add($cashOnDelivery);
  737.             $cashOnDelivery->setCustomer($this);
  738.         }
  739.         return $this;
  740.     }
  741.     public function removeCashOnDelivery(CashOnDelivery $cashOnDelivery): self
  742.     {
  743.         if ($this->cashOnDeliveries->removeElement($cashOnDelivery)) {
  744.             // set the owning side to null (unless already changed)
  745.             if ($cashOnDelivery->getCustomer() === $this) {
  746.                 $cashOnDelivery->setCustomer(null);
  747.             }
  748.         }
  749.         return $this;
  750.     }
  751.     /**
  752.      * @return Collection<int, ProductSubscription>
  753.      */
  754.     public function getProductSubscriptions(): Collection
  755.     {
  756.         return $this->productSubscriptions;
  757.     }
  758.     public function addProductSubscription(ProductSubscription $productSubscription): self
  759.     {
  760.         if (!$this->productSubscriptions->contains($productSubscription)) {
  761.             $this->productSubscriptions->add($productSubscription);
  762.             $productSubscription->setCustomer($this);
  763.         }
  764.         return $this;
  765.     }
  766.     public function removeProductSubscription(ProductSubscription $productSubscription): self
  767.     {
  768.         if ($this->productSubscriptions->removeElement($productSubscription)) {
  769.             // set the owning side to null (unless already changed)
  770.             if ($productSubscription->getCustomer() === $this) {
  771.                 $productSubscription->setCustomer(null);
  772.             }
  773.         }
  774.         return $this;
  775.     }
  776.     public function getStore(): ?Store
  777.     {
  778.         return $this->store;
  779.     }
  780.     public function setStore(?Store $store): self
  781.     {
  782.         $this->store $store;
  783.         return $this;
  784.     }
  785.     /**
  786.      * @return Collection<int, Invoice>
  787.      */
  788.     public function getInvoices(): Collection
  789.     {
  790.         return $this->invoices;
  791.     }
  792.     public function addInvoice(Invoice $invoice): self
  793.     {
  794.         if (!$this->invoices->contains($invoice)) {
  795.             $this->invoices->add($invoice);
  796.             $invoice->setCustomer($this);
  797.         }
  798.         return $this;
  799.     }
  800.     public function removeInvoice(Invoice $invoice): self
  801.     {
  802.         if ($this->invoices->removeElement($invoice)) {
  803.             // set the owning side to null (unless already changed)
  804.             if ($invoice->getCustomer() === $this) {
  805.                 $invoice->setCustomer(null);
  806.             }
  807.         }
  808.         return $this;
  809.     }
  810.     public function getCollectAddress(): ?string
  811.     {
  812.         if(!$this->collectAddress){
  813.             return $this->getAddress();
  814.         }
  815.         return $this->collectAddress;
  816.     }
  817.     public function setCollectAddress(?string $collectAddress): self
  818.     {
  819.         
  820.         $this->collectAddress $collectAddress;
  821.         return $this;
  822.     }
  823.     public function getShippingAddress(): ?string
  824.     {
  825.         if(!$this->shippingAddress){
  826.             return $this->getAddress();
  827.         }
  828.         return $this->shippingAddress;
  829.     }
  830.     public function setShippingAddress(?string $shippingAddress): self
  831.     {
  832.         $this->shippingAddress $shippingAddress;
  833.         return $this;
  834.     }
  835.     public function getCollectLat(): ?string
  836.     {
  837.         return $this->collectLat;
  838.     }
  839.     public function setCollectLat(?string $collectLat): self
  840.     {
  841.         $this->collectLat $collectLat;
  842.         return $this;
  843.     }
  844.     public function getCollectLng(): ?string
  845.     {
  846.         return $this->collectLng;
  847.     }
  848.     public function setCollectLng(string $collectLng): self
  849.     {
  850.         $this->collectLng $collectLng;
  851.         return $this;
  852.     }
  853.     public function getShippingLng(): ?string
  854.     {
  855.         return $this->shippingLng;
  856.     }
  857.     public function setShippingLng(?string $shippingLng): self
  858.     {
  859.         $this->shippingLng $shippingLng;
  860.         return $this;
  861.     }
  862.     /**
  863.      * @return Collection<int, Complaint>
  864.      */
  865.     public function getComplaints(): Collection
  866.     {
  867.         return $this->complaints;
  868.     }
  869.     public function addComplaint(Complaint $complaint): self
  870.     {
  871.         if (!$this->complaints->contains($complaint)) {
  872.             $this->complaints->add($complaint);
  873.             $complaint->setCustomer($this);
  874.         }
  875.         return $this;
  876.     }
  877.     public function removeComplaint(Complaint $complaint): self
  878.     {
  879.         if ($this->complaints->removeElement($complaint)) {
  880.             // set the owning side to null (unless already changed)
  881.             if ($complaint->getCustomer() === $this) {
  882.                 $complaint->setCustomer(null);
  883.             }
  884.         }
  885.         return $this;
  886.     }
  887.     #[Groups(["read"])]
  888.     public function getFullName(){
  889.         return $this->firstName.' '.$this->lastName;
  890.     }
  891.     #[Groups(["read"])]
  892.     public function getFullNameWithPhone(){
  893.         return $this->firstName.' '.$this->lastName.' '.$this->phone;
  894.     }
  895.     public function getMetaData(): ?array
  896.     {
  897.         return $this->metaData;
  898.     }
  899.     public function setMetaData(?array $metaData): static
  900.     {
  901.         $this->metaData $metaData;
  902.         return $this;
  903.     }
  904.     
  905.     public function getTotalOrders(){
  906.         return count($this->getOrders());
  907.     }
  908. }