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

Open in your IDE?
  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Customer;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Entity\User;
  5. use App\Flexy\ShopBundle\Entity\Order\Order;
  6. use App\Flexy\ShopBundle\Entity\Product\Comment;
  7. use App\Flexy\ShopBundle\Entity\Product\Product;
  8. use App\Flexy\ShopBundle\Repository\Customer\CustomerRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use \App\Flexy\ShopBundle\Entity\Order\ReturnOrder;
  13. /**
  14.  * @ORM\Entity(repositoryClass=CustomerRepository::class)
  15.  */
  16. #[ApiResource]
  17. class Customer
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="text", nullable=true)
  27.      */
  28.     private $description;
  29.     /**
  30.      * @ORM\Column(type="string", length=255, nullable=true)
  31.      */
  32.     private $email;
  33.     /**
  34.      * @ORM\Column(type="datetime_immutable", nullable=true)
  35.      */
  36.     private $createdAt;
  37.     /**
  38.      * @ORM\Column(type="string", length=255)
  39.      */
  40.     private $firstName;
  41.     /**
  42.      * @ORM\Column(type="string", length=255)
  43.      */
  44.     private $lastName;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $address;
  49.     /**
  50.      * @ORM\Column(type="string", length=255)
  51.      * 
  52.      */
  53.     private $phone;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $companyName;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $addressIndication;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private $country;
  66.     /**
  67.      * @ORM\Column(type="string", length=255, nullable="true")
  68.      */
  69.     private $postCode;
  70.     /**
  71.      * @ORM\OneToMany(targetEntity=Order::class, mappedBy="customer", orphanRemoval=true,cascade={"persist"})
  72.      */
  73.     private $orders;
  74.     /**
  75.      * @ORM\ManyToOne(targetEntity=CustomerGroup::class, inversedBy="customers")
  76.      */
  77.     private $customerGroup;
  78.     /**
  79.      * @ORM\OneToOne(targetEntity=User::class, cascade={"persist", "remove"})
  80.      */
  81.     private $user;
  82.     /**
  83.      * @ORM\OneToMany(targetEntity=Comment::class, mappedBy="customer")
  84.      */
  85.     private $comments;
  86.     /**
  87.      * @ORM\Column(type="string", length=255, nullable=true)
  88.      */
  89.     private $gender;
  90.     /**
  91.      * @ORM\Column(type="date", nullable=true)
  92.      */
  93.     private $dateOfBirth;
  94.     /**
  95.      * @ORM\OneToMany(targetEntity=CustomerAddress::class, mappedBy="customer",cascade={"persist"})
  96.      */
  97.     private $customerAddresses;
  98.     /**
  99.      * @ORM\OneToMany(targetEntity=Product::class, mappedBy="customer")
  100.      */
  101.     private $products;
  102.     /**
  103.      * @ORM\OneToMany(targetEntity=ReturnOrder::class, mappedBy="customer")
  104.      */
  105.     private $repayment;
  106.    
  107.    
  108.     public function __construct()
  109.     {
  110.         $this->orders = new ArrayCollection();
  111.         $this->comments = new ArrayCollection();
  112.         $this->customerAddresses = new ArrayCollection();
  113.         $this->products = new ArrayCollection();
  114.         $this->repayment = new ArrayCollection();
  115.     }
  116.     public function __toString()
  117.     {
  118.         return $this->firstName." ".$this->lastName;
  119.     }
  120.     public function getId(): ?int
  121.     {
  122.         return $this->id;
  123.     }
  124.     public function getDescription(): ?string
  125.     {
  126.         return $this->description;
  127.     }
  128.     public function setDescription(?string $description): self
  129.     {
  130.         $this->description $description;
  131.         return $this;
  132.     }
  133.     public function getEmail(): ?string
  134.     {
  135.         return $this->email;
  136.     }
  137.     public function setEmail(?string $email): self
  138.     {
  139.         $this->email $email;
  140.         return $this;
  141.     }
  142.     public function getCreatedAt(): ?\DateTimeImmutable
  143.     {
  144.         return $this->createdAt;
  145.     }
  146.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  147.     {
  148.         $this->createdAt $createdAt;
  149.         return $this;
  150.     }
  151.     public function getFirstName(): ?string
  152.     {
  153.         return $this->firstName;
  154.     }
  155.     public function setFirstName(string $firstName): self
  156.     {
  157.         $this->firstName $firstName;
  158.         return $this;
  159.     }
  160.     public function getLastName(): ?string
  161.     {
  162.         return $this->lastName;
  163.     }
  164.     public function setLastName(string $lastName): self
  165.     {
  166.         $this->lastName $lastName;
  167.         return $this;
  168.     }
  169.     public function getAddress(): ?string
  170.     {
  171.         return $this->address;
  172.     }
  173.     public function setAddress(?string $address): self
  174.     {
  175.         $this->address $address;
  176.         return $this;
  177.     }
  178.     public function getPhone(): ?string
  179.     {
  180.         return $this->phone;
  181.     }
  182.     public function setPhone(string $phone): self
  183.     {
  184.         $this->phone $phone;
  185.         return $this;
  186.     }
  187.     public function getCompanyName(): ?string
  188.     {
  189.         return $this->companyName;
  190.     }
  191.     public function setCompanyName(?string $companyName): self
  192.     {
  193.         $this->companyName $companyName;
  194.         return $this;
  195.     }
  196.     public function getAddressIndication(): ?string
  197.     {
  198.         return $this->addressIndication;
  199.     }
  200.     public function setAddressIndication(?string $addressIndication): self
  201.     {
  202.         $this->addressIndication $addressIndication;
  203.         return $this;
  204.     }
  205.     public function getCountry(): ?string
  206.     {
  207.         return $this->country;
  208.     }
  209.     public function setCountry(?string $country): self
  210.     {
  211.         $this->country $country;
  212.         return $this;
  213.     }
  214.     public function getPostCode(): ?string
  215.     {
  216.         return $this->postCode;
  217.     }
  218.     public function setPostCode(string $postCode): self
  219.     {
  220.         $this->postCode $postCode;
  221.         return $this;
  222.     }
  223.     /**
  224.      * @return Collection|Order[]
  225.      */
  226.     public function getOrders(): Collection
  227.     {
  228.         return $this->orders;
  229.     }
  230.     public function addOrder(Order $order): self
  231.     {
  232.         if (!$this->orders->contains($order)) {
  233.             $this->orders[] = $order;
  234.             $order->setCustomer($this);
  235.         }
  236.         return $this;
  237.     }
  238.     public function removeOrder(Order $order): self
  239.     {
  240.         if ($this->orders->removeElement($order)) {
  241.             // set the owning side to null (unless already changed)
  242.             if ($order->getCustomer() === $this) {
  243.                 $order->setCustomer(null);
  244.             }
  245.         }
  246.         return $this;
  247.     }
  248.     public function getCustomerGroup(): ?CustomerGroup
  249.     {
  250.         return $this->customerGroup;
  251.     }
  252.     public function setCustomerGroup(?CustomerGroup $customerGroup): self
  253.     {
  254.         $this->customerGroup $customerGroup;
  255.         return $this;
  256.     }
  257.     public function getUser(): ?User
  258.     {
  259.         return $this->user;
  260.     }
  261.     public function setUser(?User $user): self
  262.     {
  263.         $this->user $user;
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return Collection|Comment[]
  268.      */
  269.     public function getComments(): Collection
  270.     {
  271.         return $this->comments;
  272.     }
  273.     public function addComment(Comment $comment): self
  274.     {
  275.         if (!$this->comments->contains($comment)) {
  276.             $this->comments[] = $comment;
  277.             $comment->setCustomer($this);
  278.         }
  279.         return $this;
  280.     }
  281.     public function removeComment(Comment $comment): self
  282.     {
  283.         if ($this->comments->removeElement($comment)) {
  284.             // set the owning side to null (unless already changed)
  285.             if ($comment->getCustomer() === $this) {
  286.                 $comment->setCustomer(null);
  287.             }
  288.         }
  289.         return $this;
  290.     }
  291.     public function getGender(): ?string
  292.     {
  293.         return $this->gender;
  294.     }
  295.     public function setGender(?string $gender): self
  296.     {
  297.         $this->gender $gender;
  298.         return $this;
  299.     }
  300.     public function getDateOfBirth(): ?\DateTimeInterface
  301.     {
  302.         return $this->dateOfBirth;
  303.     }
  304.     public function setDateOfBirth(?\DateTimeInterface $dateOfBirth): self
  305.     {
  306.         $this->dateOfBirth $dateOfBirth;
  307.         return $this;
  308.     }
  309.     /**
  310.      * @return Collection<int, CustomerAddress>
  311.      */
  312.     public function getCustomerAddresses(): Collection
  313.     {
  314.         return $this->customerAddresses;
  315.     }
  316.     public function addCustomerAddress(CustomerAddress $customerAddress): self
  317.     {
  318.         if (!$this->customerAddresses->contains($customerAddress)) {
  319.             $this->customerAddresses[] = $customerAddress;
  320.             $customerAddress->setCustomer($this);
  321.         }
  322.         return $this;
  323.     }
  324.     public function removeCustomerAddress(CustomerAddress $customerAddress): self
  325.     {
  326.         if ($this->customerAddresses->removeElement($customerAddress)) {
  327.             // set the owning side to null (unless already changed)
  328.             if ($customerAddress->getCustomer() === $this) {
  329.                 $customerAddress->setCustomer(null);
  330.             }
  331.         }
  332.         return $this;
  333.     }
  334.     /**
  335.      * @return Collection<int, Product>
  336.      */
  337.     public function getProducts(): Collection
  338.     {
  339.         return $this->products;
  340.     }
  341.     public function addProduct(Product $product): self
  342.     {
  343.         if (!$this->products->contains($product)) {
  344.             $this->products[] = $product;
  345.             $product->setCustomer($this);
  346.         }
  347.         return $this;
  348.     }
  349.     public function removeProduct(Product $product): self
  350.     {
  351.         if ($this->products->removeElement($product)) {
  352.             // set the owning side to null (unless already changed)
  353.             if ($product->getCustomer() === $this) {
  354.                 $product->setCustomer(null);
  355.             }
  356.         }
  357.         return $this;
  358.     }
  359.     /**
  360.      * @return Collection<int, ReturnOrder>
  361.      */
  362.     public function getRepayment(): Collection
  363.     {
  364.         return $this->repayment;
  365.     }
  366.     public function addRepayment(ReturnOrder $repayment): self
  367.     {
  368.         if (!$this->repayment->contains($repayment)) {
  369.             $this->repayment[] = $repayment;
  370.             $repayment->setCustomer($this);
  371.         }
  372.         return $this;
  373.     }
  374.     public function removeRepayment(ReturnOrder $repayment): self
  375.     {
  376.         if ($this->repayment->removeElement($repayment)) {
  377.             // set the owning side to null (unless already changed)
  378.             if ($repayment->getCustomer() === $this) {
  379.                 $repayment->setCustomer(null);
  380.             }
  381.         }
  382.         return $this;
  383.     }
  384.    
  385.    
  386.     
  387.      
  388. }