src/Flexy/ShopBundle/Entity/Customer/Customer.php line 36
<?phpnamespace App\Flexy\ShopBundle\Entity\Customer;use ApiPlatform\Core\Annotation\ApiResource;use App\Entity\User;use App\Flexy\ShopBundle\Entity\Accounting\Invoice;use App\Flexy\ShopBundle\Entity\Order\Order;use App\Flexy\ShopBundle\Entity\Payment\BankBookItem;use App\Flexy\ShopBundle\Entity\Product\Comment;use App\Flexy\ShopBundle\Entity\Product\ProductSubscription;use App\Flexy\ShopBundle\Entity\Promotion\Coupon;use App\Flexy\ShopBundle\Entity\Shipping\CashOnDelivery;use App\Flexy\ShopBundle\Entity\Shipping\CityRegion;use App\Flexy\ShopBundle\Entity\Shipping\Shipment;use App\Flexy\ShopBundle\Entity\Store\Store;use App\Flexy\ShopBundle\Entity\Vendor\Vendor;use App\Flexy\ShopBundle\Repository\Customer\CustomerRepository;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\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints as Assert;use Gedmo\Mapping\Annotation as Gedmo;#[ApiResource(denormalizationContext: ['groups' => ['write']],)]#[ORM\Entity(repositoryClass: CustomerRepository::class)]#[UniqueEntity(fields: ['email'],message: 'Ce compte déja existe.',)]#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]class Customer implements \Stringable{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column(type: 'integer')]private $id;#[ORM\Column(type: 'text', nullable: true)]private ?string $description = null;#[Groups("write")]#[ORM\Column(type: 'string', length: 255, nullable: false, unique: true)]#[Assert\Email]#[Assert\NotNull]#[Assert\NotBlank]private ?string $email = null;#[ORM\Column(type: 'datetime', nullable: true)]private ?\DateTime $createdAt = null;#[Groups("write")]#[ORM\Column(type: 'string', length: 255)]private ?string $firstName = null;#[Groups("write")]#[ORM\Column(type: 'string', length: 255)]private ?string $lastName = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $address = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private $city;#[Groups("write")]#[ORM\Column(type: 'string', length: 255)]#[Assert\Regex(pattern: '/^[0-9]*$/', match: true, message: 'Veuillez entrer une numéro de téléphone valide(en chiffres)')]#[Assert\Length(min: 10)]private ?string $phone = null;#[Groups("write")]#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $companyName = null;#[Groups("write")]#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $addressIndication = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $country = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $postCode = null;#[ORM\OneToMany(targetEntity: Order::class, mappedBy: 'customer', orphanRemoval: true, cascade: ['persist', 'remove'])]private \Doctrine\Common\Collections\Collection $orders;#[Groups("write")]#[ORM\ManyToOne(targetEntity: CustomerGroup::class, inversedBy: 'customers', cascade: ['persist'])]private ?\App\Flexy\ShopBundle\Entity\Customer\CustomerGroup $customerGroup = null;#[Groups("write")]#[ORM\OneToOne(targetEntity: User::class, orphanRemoval: true, cascade: ['persist', 'remove'])]private ?\App\Entity\User $user = null;#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'customer')]private \Doctrine\Common\Collections\Collection|array $comments;#[Groups("write")]#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $gender = null;#[Groups("write")]#[ORM\Column(type: 'date', nullable: true)]private ?\DateTimeInterface $dateOfBirth = null;#[ORM\OneToMany(targetEntity: CustomerAddress::class, mappedBy: 'customer', cascade: ['persist', 'remove'])]private \Doctrine\Common\Collections\Collection|array $customerAddresses;#[ORM\OneToMany(targetEntity: CustomerWalletPoint::class, mappedBy: 'customer', orphanRemoval: true, cascade: ['persist', 'remove'])]private \Doctrine\Common\Collections\Collection|array $customerWalletPoints;#[ORM\ManyToOne(targetEntity: Vendor::class, inversedBy: 'customers')]private ?\App\Flexy\ShopBundle\Entity\Vendor\Vendor $vendor = null;#[ORM\ManyToOne(targetEntity: CityRegion::class)]private $cityRegion;#[ORM\OneToMany(targetEntity: PackEngagement::class, mappedBy: 'customer', cascade: ['remove'], orphanRemoval: true)]private \Doctrine\Common\Collections\Collection|array $packEngagements;#[Groups("write")]#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $sponsorshipCode = null;#[Groups("write")]#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $image = null;#[ORM\ManyToMany(targetEntity: Coupon::class, mappedBy: 'allowedCustomers')]private \Doctrine\Common\Collections\Collection|array $affectedCoupons;#[ORM\OneToMany(targetEntity: Coupon::class, mappedBy: 'onlyThisCustomer')]private \Doctrine\Common\Collections\Collection|array $affectedCouponsOnlyForMe;#[Groups("write")]#[ORM\Column(type: 'boolean', nullable: true)]private $canReceiveMails;#[Groups("write")]#[ORM\Column(type: 'boolean', nullable: true)]private $canReceiveSms;#[ORM\Column(type: 'string', length: 255, nullable: true)]private $blindPassword;#[ORM\Column(nullable: true)]private ?\DateTimeImmutable $deletedAt = null;#[ORM\OneToMany(mappedBy: 'senderCustomer', targetEntity: Shipment::class)]private Collection $sentShipments;#[ORM\OneToMany(mappedBy: 'recipientCustomer', targetEntity: Shipment::class)]private Collection $receivedShipments;#[ORM\OneToMany(mappedBy: 'customer', targetEntity: BankBookItem::class)]private Collection $bankBookItems;#[ORM\OneToMany(mappedBy: 'customer', targetEntity: CashOnDelivery::class)]private Collection $cashOnDeliveries;#[ORM\OneToMany(mappedBy: 'customer', targetEntity: ProductSubscription::class)]private Collection $productSubscriptions;#[ORM\ManyToOne(inversedBy: 'customers')]private ?Store $store = null;#[ORM\OneToMany(mappedBy: 'customer', targetEntity: Invoice::class)]private Collection $invoices;#[ORM\Column(length: 255, nullable: true)]#[Groups("write")]private ?string $collectAddress = null;#[ORM\Column(length: 255, nullable: true)]#[Groups("write")]private ?string $shippingAddress = null;#[ORM\Column(length: 255, nullable: true)]#[Groups("write")]private ?string $collectLat = null;#[ORM\Column(length: 255, nullable: true)]#[Groups("write")]private ?string $collectLng = null;#[ORM\Column(length: 255, nullable: true)]#[Groups("write")]private ?string $shippingLng = null;#[ORM\OneToMany(mappedBy: 'customer', targetEntity: Complaint::class)]private Collection $complaints;#[ORM\Column(length: 255, nullable: true)]private ?string $code = null;#[ORM\Column(length: 255, nullable: true)]private ?string $reference = null;#[ORM\Column(length: 255, nullable: true)]private ?string $identityNumber = null;#[ORM\OneToMany(mappedBy: 'customer', targetEntity: Visit::class)]private Collection $visits;#[ORM\Column(nullable: true)]private ?bool $is_actif = null;public function __construct(){$this->sentShipments = new ArrayCollection();$this->receivedShipments = new ArrayCollection();$this->bankBookItems = new ArrayCollection();$this->cashOnDeliveries = new ArrayCollection();$this->productSubscriptions = new ArrayCollection();$this->invoices = new ArrayCollection();$this->customerWalletPoints = new ArrayCollection();$this->createdAt = new \DateTime();$this->complaints = new ArrayCollection();$this->orders = new ArrayCollection();$this->visits = new ArrayCollection();}public function __toString(): string{return $this->firstName." ".$this->lastName;}public function getId(): ?int{return $this->id;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): self{$this->description = $description;return $this;}public function getEmail(): ?string{return $this->email;}public function setEmail(?string $email): self{$this->email = $email;return $this;}public function getCreatedAt(): ?\DateTime{return $this->createdAt;}public function setCreatedAt(?\DateTime $createdAt): self{$this->createdAt = $createdAt;return $this;}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 getAddress(): ?string{return $this->address;}public function setAddress(?string $address): self{$this->address = $address;return $this;}public function getPhone(): ?string{return $this->phone;}public function setPhone(string $phone): self{$this->phone = $phone;return $this;}public function getCompanyName(): ?string{return $this->companyName;}public function setCompanyName(?string $companyName): self{$this->companyName = $companyName;return $this;}public function getAddressIndication(): ?string{return $this->addressIndication;}public function setAddressIndication(?string $addressIndication): self{$this->addressIndication = $addressIndication;return $this;}public function getCountry(): ?string{return $this->country;}public function setCountry(?string $country): self{$this->country = $country;return $this;}public function getPostCode(): ?string{return $this->postCode;}public function setPostCode(string $postCode): self{$this->postCode = $postCode;return $this;}/*** @return Collection|Order[]*/public function getOrders(): Collection{return $this->orders;}public function addOrder(Order $order): self{if (!$this->orders->contains($order)) {$this->orders[] = $order;$order->setCustomer($this);}return $this;}public function removeOrder(Order $order): self{if ($this->orders->removeElement($order)) {// set the owning side to null (unless already changed)if ($order->getCustomer() === $this) {$order->setCustomer(null);}}return $this;}public function getCustomerGroup(): ?CustomerGroup{return $this->customerGroup;}public function setCustomerGroup(?CustomerGroup $customerGroup): self{$this->customerGroup = $customerGroup;return $this;}public function getUser(): ?User{return $this->user;}public function setUser(?User $user): self{$this->user = $user;return $this;}/*** @return Collection|Comment[]*/public function getComments(): Collection{return $this->comments;}public function addComment(Comment $comment): self{if (!$this->comments->contains($comment)) {$this->comments[] = $comment;$comment->setCustomer($this);}return $this;}public function removeComment(Comment $comment): self{if ($this->comments->removeElement($comment)) {// set the owning side to null (unless already changed)if ($comment->getCustomer() === $this) {$comment->setCustomer(null);}}return $this;}public function getGender(): ?string{return $this->gender;}public function setGender(?string $gender): self{$this->gender = $gender;return $this;}public function getDateOfBirth(): ?\DateTimeInterface{return $this->dateOfBirth;}public function setDateOfBirth(?\DateTimeInterface $dateOfBirth): self{$this->dateOfBirth = $dateOfBirth;return $this;}/*** @return Collection<int, CustomerAddress>*/public function getCustomerAddresses(): Collection{return $this->customerAddresses;}public function addCustomerAddress(CustomerAddress $customerAddress): self{if (!$this->customerAddresses->contains($customerAddress)) {$this->customerAddresses[] = $customerAddress;$customerAddress->setCustomer($this);}return $this;}public function removeCustomerAddress(CustomerAddress $customerAddress): self{if ($this->customerAddresses->removeElement($customerAddress)) {// set the owning side to null (unless already changed)if ($customerAddress->getCustomer() === $this) {$customerAddress->setCustomer(null);}}return $this;}/*** @return Collection<int, CustomerWalletPoint>*/public function getCustomerWalletPoints(): Collection{return $this->customerWalletPoints;}public function addCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self{if (!$this->customerWalletPoints->contains($customerWalletPoint)) {$this->customerWalletPoints[] = $customerWalletPoint;$customerWalletPoint->setCustomer($this);}return $this;}public function removeCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self{if ($this->customerWalletPoints->removeElement($customerWalletPoint)) {// set the owning side to null (unless already changed)if ($customerWalletPoint->getCustomer() === $this) {$customerWalletPoint->setCustomer(null);}}return $this;}public function getCredit(){$credit = 0;foreach($this->getCustomerWalletPoints() as $singleWalletPoint){$credit = $credit + $singleWalletPoint->getPoints();}return $credit;}public function getVendor(): ?Vendor{return $this->vendor;}public function setVendor(?Vendor $vendor): self{$this->vendor = $vendor;return $this;}/*** @return Collection<int, PackEngagement>*/public function getPackEngagements(): Collection{return $this->packEngagements;}public function addPackEngagement(PackEngagement $packEngagement): self{if (!$this->packEngagements->contains($packEngagement)) {$this->packEngagements[] = $packEngagement;$packEngagement->setCustomer($this);}return $this;}public function removePackEngagement(PackEngagement $packEngagement): self{if ($this->packEngagements->removeElement($packEngagement)) {// set the owning side to null (unless already changed)if ($packEngagement->getCustomer() === $this) {$packEngagement->setCustomer(null);}}return $this;}public function getSponsorshipCode(): ?string{return $this->sponsorshipCode;}public function setSponsorshipCode(?string $sponsorshipCode): self{$this->sponsorshipCode = $sponsorshipCode;return $this;}public function getMySponsorshipCode(){return "PRN0000".$this->getId();}public function getImage(): ?string{return $this->image;}public function setImage(?string $image): self{$this->image = $image;return $this;}/*** @return Collection<int, Coupon>*/public function getAffectedCoupons(): Collection{return $this->affectedCoupons;}public function addAffectedCoupon(Coupon $affectedCoupon): self{if (!$this->affectedCoupons->contains($affectedCoupon)) {$this->affectedCoupons[] = $affectedCoupon;$affectedCoupon->addAllowedCustomer($this);}return $this;}public function removeAffectedCoupon(Coupon $affectedCoupon): self{if ($this->affectedCoupons->removeElement($affectedCoupon)) {$affectedCoupon->removeAllowedCustomer($this);}return $this;}/*** @return Collection<int, Coupon>*/public function getAffectedCouponsOnlyForMe(): Collection{return $this->affectedCouponsOnlyForMe;}public function addAffectedCouponsOnlyForMe(Coupon $affectedCouponsOnlyForMe): self{if (!$this->affectedCouponsOnlyForMe->contains($affectedCouponsOnlyForMe)) {$this->affectedCouponsOnlyForMe[] = $affectedCouponsOnlyForMe;$affectedCouponsOnlyForMe->setOnlyThisCustomer($this);}return $this;}public function removeAffectedCouponsOnlyForMe(Coupon $affectedCouponsOnlyForMe): self{if ($this->affectedCouponsOnlyForMe->removeElement($affectedCouponsOnlyForMe)) {// set the owning side to null (unless already changed)if ($affectedCouponsOnlyForMe->getOnlyThisCustomer() === $this) {$affectedCouponsOnlyForMe->setOnlyThisCustomer(null);}}return $this;}/*** Get the value of canReceiveMails*/public function getCanReceiveMails(){return $this->canReceiveMails;}/*** Set the value of canReceiveMails** @return self*/public function setCanReceiveMails($canReceiveMails){$this->canReceiveMails = $canReceiveMails;return $this;}/*** Get the value of canReceiveSms*/public function getCanReceiveSms(){return $this->canReceiveSms;}/*** Set the value of canReceiveSms** @return self*/public function setCanReceiveSms($canReceiveSms){$this->canReceiveSms = $canReceiveSms;return $this;}/*** Get the value of blindPassword*/public function getBlindPassword(){return $this->blindPassword;}/*** Set the value of blindPassword** @return self*/public function setBlindPassword($blindPassword){$this->blindPassword = $blindPassword;return $this;}/*** Get the value of city*/public function getCity(){return $this->city;}/*** Set the value of city** @return self*/public function setCity($city){$this->city = $city;return $this;}/*** Get the value of cityRegion*/public function getCityRegion(){return $this->cityRegion;}/*** Set the value of cityRegion** @return self*/public function setCityRegion($cityRegion){$this->cityRegion = $cityRegion;return $this;}public function getDeletedAt(): ?\DateTimeImmutable{return $this->deletedAt;}public function setDeletedAt(?\DateTimeImmutable $deletedAt): self{$this->deletedAt = $deletedAt;return $this;}/*** @return Collection<int, Shipment>*/public function getSentShipments(): Collection{return $this->sentShipments;}public function addSentShipment(Shipment $sentShipment): self{if (!$this->sentShipments->contains($sentShipment)) {$this->sentShipments->add($sentShipment);$sentShipment->setSenderCustomer($this);}return $this;}public function removeSentShipment(Shipment $sentShipment): self{if ($this->sentShipments->removeElement($sentShipment)) {// set the owning side to null (unless already changed)if ($sentShipment->getSenderCustomer() === $this) {$sentShipment->setSenderCustomer(null);}}return $this;}/*** @return Collection<int, Shipment>*/public function getReceivedShipments(): Collection{return $this->receivedShipments;}public function addReceivedShipment(Shipment $receivedShipment): self{if (!$this->receivedShipments->contains($receivedShipment)) {$this->receivedShipments->add($receivedShipment);$receivedShipment->setRecipientCustomer($this);}return $this;}public function removeReceivedShipment(Shipment $receivedShipment): self{if ($this->receivedShipments->removeElement($receivedShipment)) {// set the owning side to null (unless already changed)if ($receivedShipment->getRecipientCustomer() === $this) {$receivedShipment->setRecipientCustomer(null);}}return $this;}/*** @return Collection<int, BankBookItem>*/public function getBankBookItems(): Collection{return $this->bankBookItems;}public function addBankBookItem(BankBookItem $bankBookItem): self{if (!$this->bankBookItems->contains($bankBookItem)) {$this->bankBookItems->add($bankBookItem);$bankBookItem->setCustomer($this);}return $this;}public function removeBankBookItem(BankBookItem $bankBookItem): self{if ($this->bankBookItems->removeElement($bankBookItem)) {// set the owning side to null (unless already changed)if ($bankBookItem->getCustomer() === $this) {$bankBookItem->setCustomer(null);}}return $this;}/*** @return Collection<int, CashOnDelivery>*/public function getCashOnDeliveries(): Collection{return $this->cashOnDeliveries;}public function addCashOnDelivery(CashOnDelivery $cashOnDelivery): self{if (!$this->cashOnDeliveries->contains($cashOnDelivery)) {$this->cashOnDeliveries->add($cashOnDelivery);$cashOnDelivery->setCustomer($this);}return $this;}public function removeCashOnDelivery(CashOnDelivery $cashOnDelivery): self{if ($this->cashOnDeliveries->removeElement($cashOnDelivery)) {// set the owning side to null (unless already changed)if ($cashOnDelivery->getCustomer() === $this) {$cashOnDelivery->setCustomer(null);}}return $this;}/*** @return Collection<int, ProductSubscription>*/public function getProductSubscriptions(): Collection{return $this->productSubscriptions;}public function addProductSubscription(ProductSubscription $productSubscription): self{if (!$this->productSubscriptions->contains($productSubscription)) {$this->productSubscriptions->add($productSubscription);$productSubscription->setCustomer($this);}return $this;}public function removeProductSubscription(ProductSubscription $productSubscription): self{if ($this->productSubscriptions->removeElement($productSubscription)) {// set the owning side to null (unless already changed)if ($productSubscription->getCustomer() === $this) {$productSubscription->setCustomer(null);}}return $this;}public function getStore(): ?Store{return $this->store;}public function setStore(?Store $store): self{$this->store = $store;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->add($invoice);$invoice->setCustomer($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->getCustomer() === $this) {$invoice->setCustomer(null);}}return $this;}public function getCollectAddress(): ?string{return $this->collectAddress;}public function setCollectAddress(?string $collectAddress): self{$this->collectAddress = $collectAddress;return $this;}public function getShippingAddress(): ?string{return $this->shippingAddress;}public function setShippingAddress(?string $shippingAddress): self{$this->shippingAddress = $shippingAddress;return $this;}public function getCollectLat(): ?string{return $this->collectLat;}public function setCollectLat(?string $collectLat): self{$this->collectLat = $collectLat;return $this;}public function getCollectLng(): ?string{return $this->collectLng;}public function setCollectLng(string $collectLng): self{$this->collectLng = $collectLng;return $this;}public function getShippingLng(): ?string{return $this->shippingLng;}public function setShippingLng(?string $shippingLng): self{$this->shippingLng = $shippingLng;return $this;}/*** @return Collection<int, Complaint>*/public function getComplaints(): Collection{return $this->complaints;}public function addComplaint(Complaint $complaint): self{if (!$this->complaints->contains($complaint)) {$this->complaints->add($complaint);$complaint->setCustomer($this);}return $this;}public function removeComplaint(Complaint $complaint): self{if ($this->complaints->removeElement($complaint)) {// set the owning side to null (unless already changed)if ($complaint->getCustomer() === $this) {$complaint->setCustomer(null);}}return $this;}public function getCode(): ?string{return $this->code;}public function setCode(?string $code): self{$this->code = $code;return $this;}public function getReference(): ?string{return $this->reference;}public function setReference(?string $reference): self{$this->reference = $reference;return $this;}public function getIdentityNumber(): ?string{return $this->identityNumber;}public function setIdentityNumber(?string $identityNumber): self{$this->identityNumber = $identityNumber;return $this;}/*** @return Collection<int, Visit>*/public function getVisits(): Collection{return $this->visits;}public function addVisit(Visit $visit): static{if (!$this->visits->contains($visit)) {$this->visits->add($visit);$visit->setCustomer($this);}return $this;}public function removeVisit(Visit $visit): static{if ($this->visits->removeElement($visit)) {// set the owning side to null (unless already changed)if ($visit->getCustomer() === $this) {$visit->setCustomer(null);}}return $this;}public function isIsActif(): ?bool{return $this->is_actif;}public function setIsActif(?bool $is_actif): static{$this->is_actif = $is_actif;return $this;}}