src/Entity/Gos/CartParticipant.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\CartParticipantRepository")
  8.  * @ORM\HasLifecycleCallbacks
  9.  */
  10. class CartParticipant
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255, nullable=true)
  20.      */
  21.     private $firstName;
  22.     /**
  23.      * @ORM\Column(type="string", length=255, nullable=true)
  24.      */
  25.     private $lastName;
  26.     /**
  27.      * @ORM\Column(type="string", length=30, nullable=true)
  28.      */
  29.     private $phoneNumber;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $email;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $position;
  38.     /**
  39.      * @ORM\Column(type="string", length=8, nullable=true)
  40.      */
  41.     private $pwz;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private $correspondenceFirstName;
  48.     /**
  49.      * @var string
  50.      *
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      */
  53.     private $correspondenceLastName;
  54.     /**
  55.      * @var string
  56.      *
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $correspondenceAddress;
  60.     /**
  61.      * @var string
  62.      *
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private $correspondenceCity;
  66.     /**
  67.      * @var string
  68.      *
  69.      * @ORM\Column(type="string", length=9, nullable=true)
  70.      */
  71.     private $correspondencePostalcode;
  72.     /**
  73.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductCart", inversedBy="cartParticipant")
  74.      * @ORM\JoinColumn(onDelete="CASCADE")
  75.      */
  76.     private $productCart;
  77.     /**
  78.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductVariant", inversedBy="cartParticipantsPrimary")
  79.      * @ORM\JoinColumn()
  80.      */
  81.     private $primaryProductVariant;
  82.     /**
  83.      * @ORM\ManyToMany(targetEntity="EventProductVariantGroupItem", inversedBy="cartParticipants")
  84.      * @ORM\JoinColumn()
  85.      */
  86.     private $productVariantGroupItems;
  87.     /**
  88.      * @ORM\Column(type="datetime")
  89.      */
  90.     private $createdAt;
  91.     /**
  92.      * @ORM\Column(type="datetime", nullable=true)
  93.      */
  94.     private $updatedAt;
  95.     /**
  96.      * @ORM\Column(type="boolean", nullable=true)
  97.      */
  98.     private $productDuplicationMessageDisplayed;
  99.     public function hasAddress()
  100.     {
  101.         if (
  102.             empty($this->correspondenceFirstName)
  103.             || empty($this->correspondenceLastName)
  104.             || empty($this->correspondenceAddress)
  105.             || empty($this->correspondenceCity)
  106.             || empty($this->correspondencePostalcode)
  107.         )
  108.         {
  109.             return false;
  110.         }
  111.         return true;
  112.     }
  113.     public function removeAllProductVariantGroupItem(): self
  114.     {
  115.         foreach ($this->getProductVariantGroupItems() as $productVariantGroupItem)
  116.         {
  117.             if ($this->productVariantGroupItems->contains($productVariantGroupItem))
  118.             {
  119.                 $this->productVariantGroupItems->removeElement($productVariantGroupItem);
  120.             }
  121.         }
  122.         return $this;
  123.     }
  124.     public function hasProductVariantGroupItem($id)
  125.     {
  126.         foreach ($this->getProductVariantGroupItems() as $productVariantGroupItem)
  127.         {
  128.             if ($productVariantGroupItem->getId() == $id)
  129.             {
  130.                 return true;
  131.             }
  132.         }
  133.         return false;
  134.     }
  135.     public function getGroupedProductVariantGroupItems()
  136.     {
  137.         $groupedProducts = array();
  138.         foreach ($this->getProductVariantGroupItems() as $productVariantGroupItem)
  139.         {
  140.             $group $productVariantGroupItem->getProductVariantGroup();
  141.             $groupedProducts[$group->getId()]['group']   = $group;
  142.             $groupedProducts[$group->getId()]['items'][] = $productVariantGroupItem;
  143.         }
  144.         return $groupedProducts;
  145.     }
  146.     /** @ORM\PrePersist() */
  147.     public function prePersist()
  148.     {
  149.         $this->createdAt = new \DateTime();
  150.     }
  151.     /** @ORM\PreUpdate() */
  152.     public function preUpdate()
  153.     {
  154.         $this->updatedAt = new \DateTime();
  155.     }
  156.     public function __toString()
  157.     {
  158.         return (string)$this->email;
  159.     }
  160.     //------------------------------ setters & getters
  161.     public function __construct()
  162.     {
  163.         $this->productVariantGroupItems = new ArrayCollection();
  164.     }
  165.     public function getId(): ?int
  166.     {
  167.         return $this->id;
  168.     }
  169.     public function getFirstName(): ?string
  170.     {
  171.         return $this->firstName;
  172.     }
  173.     public function setFirstName(?string $firstName): self
  174.     {
  175.         $this->firstName $firstName;
  176.         return $this;
  177.     }
  178.     public function getLastName(): ?string
  179.     {
  180.         return $this->lastName;
  181.     }
  182.     public function setLastName(?string $lastName): self
  183.     {
  184.         $this->lastName $lastName;
  185.         return $this;
  186.     }
  187.     public function getPhoneNumber(): ?string
  188.     {
  189.         return $this->phoneNumber;
  190.     }
  191.     public function setPhoneNumber(?string $phoneNumber): self
  192.     {
  193.         $this->phoneNumber $phoneNumber;
  194.         return $this;
  195.     }
  196.     public function getEmail(): ?string
  197.     {
  198.         return $this->email;
  199.     }
  200.     public function setEmail(string $email): self
  201.     {
  202.         $this->email $email;
  203.         return $this;
  204.     }
  205.     public function getPosition(): ?string
  206.     {
  207.         return $this->position;
  208.     }
  209.     public function setPosition(?string $position): self
  210.     {
  211.         $this->position $position;
  212.         return $this;
  213.     }
  214.     public function getPwz(): ?string
  215.     {
  216.         return $this->pwz;
  217.     }
  218.     public function setPwz(?string $pwz): self
  219.     {
  220.         $this->pwz $pwz;
  221.         return $this;
  222.     }
  223.     public function getCreatedAt(): ?\DateTimeInterface
  224.     {
  225.         return $this->createdAt;
  226.     }
  227.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  228.     {
  229.         $this->createdAt $createdAt;
  230.         return $this;
  231.     }
  232.     public function getUpdatedAt(): ?\DateTimeInterface
  233.     {
  234.         return $this->updatedAt;
  235.     }
  236.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  237.     {
  238.         $this->updatedAt $updatedAt;
  239.         return $this;
  240.     }
  241.     public function getProductCart(): ?ProductCart
  242.     {
  243.         return $this->productCart;
  244.     }
  245.     public function setProductCart(?ProductCart $productCart): self
  246.     {
  247.         $this->productCart $productCart;
  248.         return $this;
  249.     }
  250.     public function getPrimaryProductVariant(): ?ProductVariant
  251.     {
  252.         return $this->primaryProductVariant;
  253.     }
  254.     public function setPrimaryProductVariant(?ProductVariant $primaryProductVariant): self
  255.     {
  256.         $this->primaryProductVariant $primaryProductVariant;
  257.         return $this;
  258.     }
  259.     /**
  260.      * @return Collection|EventProductVariantGroupItem[]
  261.      */
  262.     public function getProductVariantGroupItems(): Collection
  263.     {
  264.         return $this->productVariantGroupItems;
  265.     }
  266.     public function addProductVariantGroupItem(EventProductVariantGroupItem $productVariantGroupItem): self
  267.     {
  268.         if (!$this->productVariantGroupItems->contains($productVariantGroupItem)) {
  269.             $this->productVariantGroupItems[] = $productVariantGroupItem;
  270.         }
  271.         return $this;
  272.     }
  273.     public function removeProductVariantGroupItem(EventProductVariantGroupItem $productVariantGroupItem): self
  274.     {
  275.         if ($this->productVariantGroupItems->contains($productVariantGroupItem)) {
  276.             $this->productVariantGroupItems->removeElement($productVariantGroupItem);
  277.         }
  278.         return $this;
  279.     }
  280.     public function getCorrespondenceFirstName(): ?string
  281.     {
  282.         return $this->correspondenceFirstName;
  283.     }
  284.     public function setCorrespondenceFirstName(?string $correspondenceFirstName): self
  285.     {
  286.         $this->correspondenceFirstName $correspondenceFirstName;
  287.         return $this;
  288.     }
  289.     public function getCorrespondenceLastName(): ?string
  290.     {
  291.         return $this->correspondenceLastName;
  292.     }
  293.     public function setCorrespondenceLastName(?string $correspondenceLastName): self
  294.     {
  295.         $this->correspondenceLastName $correspondenceLastName;
  296.         return $this;
  297.     }
  298.     public function getCorrespondenceAddress(): ?string
  299.     {
  300.         return $this->correspondenceAddress;
  301.     }
  302.     public function setCorrespondenceAddress(?string $correspondenceAddress): self
  303.     {
  304.         $this->correspondenceAddress $correspondenceAddress;
  305.         return $this;
  306.     }
  307.     public function getCorrespondenceCity(): ?string
  308.     {
  309.         return $this->correspondenceCity;
  310.     }
  311.     public function setCorrespondenceCity(?string $correspondenceCity): self
  312.     {
  313.         $this->correspondenceCity $correspondenceCity;
  314.         return $this;
  315.     }
  316.     public function getCorrespondencePostalcode(): ?string
  317.     {
  318.         return $this->correspondencePostalcode;
  319.     }
  320.     public function setCorrespondencePostalcode(?string $correspondencePostalcode): self
  321.     {
  322.         $this->correspondencePostalcode $correspondencePostalcode;
  323.         return $this;
  324.     }
  325.     public function getProductDuplicationMessageDisplayed(): ?bool
  326.     {
  327.         return $this->productDuplicationMessageDisplayed;
  328.     }
  329.     public function setProductDuplicationMessageDisplayed(?bool $productDuplicationMessageDisplayed): self
  330.     {
  331.         $this->productDuplicationMessageDisplayed $productDuplicationMessageDisplayed;
  332.         return $this;
  333.     }
  334. }