src/Entity/Offer/OfferItem.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Offer;
  3. use App\Entity\Item\Item;
  4. use App\Entity\Traits\IdTrait;
  5. use App\Entity\Traits\TimeStampAbleTrait;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * @ORM\Entity(repositoryClass=OfferItemRepository::class)
  11.  * @ORM\HasLifecycleCallbacks
  12.  */
  13. class OfferItem
  14. {
  15.     use IdTrait;
  16.     use TimeStampAbleTrait;
  17.     /**
  18.      * @ORM\Column(type="boolean", nullable="true")
  19.      */
  20.     private ?bool $niceToHaveButton;
  21.     /**
  22.      * @ORM\Column(type="text", nullable="true")
  23.      */
  24.     private ?string $text;
  25.     /**
  26.      * @ORM\Column(type="string", length=255, nullable="true")
  27.      */
  28.     private ?string $secondLevel;
  29.     /**
  30.      * @ORM\Column(type="string", length=255, nullable="true")
  31.      */
  32.     private ?string $thirdLevel;
  33.     /**
  34.      * @ORM\ManyToMany(targetEntity=Item::class, cascade={"persist"})
  35.      */
  36.     private $items;
  37.     public function __construct(
  38.         /**
  39.          * @ORM\ManyToOne(targetEntity=Offer::class, inversedBy="offerItems")
  40.          */
  41.         private $offer,
  42.         /**
  43.          * @ORM\Column(type="boolean", nullable="true")
  44.          */
  45.         private ?bool $niceToHave,
  46.         /**
  47.          * @ORM\Column(type="string", length=255, nullable="true")
  48.          */
  49.         private ?string $categoryType,
  50.         /**
  51.          * @ORM\Column(type="integer", length=255, nullable="true")
  52.          */
  53.         private ?int $itemCategoryId,
  54.         /**
  55.          * @ORM\Column(type="string", length=255, nullable="true")
  56.          */
  57.         private ?string $fieldType,
  58.         /**
  59.          * @ORM\Column(type="string", length=255, nullable="true")
  60.          */
  61.         private ?string $offerItemNamePL,
  62.         /**
  63.          * @ORM\Column(type="string", length=255, nullable="true")
  64.          */
  65.         private ?string $offerItemNameEN,
  66.         /**
  67.          * @ORM\Column(type="boolean", nullable=true)
  68.          */
  69.         private ?bool $isNameOffer,
  70.         /**
  71.          * @ORM\Column(type="boolean", nullable=true)
  72.          */
  73.         private ?bool $isLevelOffer,
  74.         /**
  75.          * @ORM\Column(type="string", length=255, nullable="true")
  76.          */
  77.         private ?string $fieldTypeView,
  78.         /**
  79.          * @ORM\Column(type="boolean", nullable=true)
  80.          */
  81.         private $showLabel = false
  82.     ){
  83.         $this->items = new ArrayCollection();
  84.     }
  85.     public function __clone()
  86.     {
  87.         $this->id    = null;
  88.         $this->items = null;
  89.         $this->offer = null;
  90.     }
  91.     public function cloneObject(Offer $offer): self
  92.     {
  93.         $clone = clone $this;
  94.         $clone->offer = $offer;
  95.         return $clone;
  96.     }
  97.     public function addItemsToOfferItem(array $items, OfferItem $offerItem): void
  98.     {
  99.         $offerItem->items = new ArrayCollection();
  100.         foreach($items as $item){
  101.             $offerItem->addItem($item);
  102.         }
  103.     }
  104.     /**
  105.      * @return mixed
  106.      */
  107.     public function getOffer()
  108.     {
  109.         return $this->offer;
  110.     }
  111.     /**
  112.      * @param mixed $offer
  113.      */
  114.     public function setOffer($offer): self
  115.     {
  116.         $this->offer = $offer;
  117.         return $this;
  118.     }
  119.     /**
  120.      * @return bool|null
  121.      */
  122.     public function getNiceToHave(): ?bool
  123.     {
  124.         return $this->niceToHave;
  125.     }
  126.     /**
  127.      * @param bool|null $niceToHave
  128.      */
  129.     public function setNiceToHave(?bool $niceToHave): self
  130.     {
  131.         $this->niceToHave = $niceToHave;
  132.         return $this;
  133.     }
  134.     /**
  135.      * @return bool|null
  136.      */
  137.     public function getNiceToHaveButton(): ?bool
  138.     {
  139.         return $this->niceToHaveButton;
  140.     }
  141.     /**
  142.      * @param bool|null $niceToHaveButton
  143.      */
  144.     public function setNiceToHaveButton(?bool $niceToHaveButton): self
  145.     {
  146.         $this->niceToHaveButton = $niceToHaveButton;
  147.         return $this;
  148.     }
  149.     /**
  150.      * @return string|null
  151.      */
  152.     public function getCategoryType(): ?string
  153.     {
  154.         return $this->categoryType;
  155.     }
  156.     /**
  157.      * @param string|null $categoryType
  158.      */
  159.     public function setCategoryType(?string $categoryType): void
  160.     {
  161.         $this->categoryType = $categoryType;
  162.     }
  163.     /**
  164.      * @return string|null
  165.      */
  166.     public function getText(): ?string
  167.     {
  168.         return $this->text;
  169.     }
  170.     /**
  171.      * @param string|null $text
  172.      */
  173.     public function setText(?string $text): self
  174.     {
  175.         $this->text = $text;
  176.         return $this;
  177.     }
  178.     /**
  179.      * @return int|null
  180.      */
  181.     public function getItemCategoryId(): ?int
  182.     {
  183.         return $this->itemCategoryId;
  184.     }
  185.     /**
  186.      * @param int|null $itemCategoryId
  187.      */
  188.     public function setItemCategoryId(?int $itemCategoryId): self
  189.     {
  190.         $this->itemCategoryId = $itemCategoryId;
  191.         return $this;
  192.     }
  193.     /**
  194.      * @return Collection|\App\Entity\Item\Item[]
  195.      */
  196.     public function getItems(): Collection
  197.     {
  198.         return $this->items;
  199.     }
  200.     public function addItem(Item $item): self
  201.     {
  202.         if (!$this->items->contains($item)) {
  203.             $this->items[] = $item;
  204.         }
  205.         return $this;
  206.     }
  207.     public function removeItem(Item $item): self
  208.     {
  209.         $this->items->removeElement($item);
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return string|null
  214.      */
  215.     public function getFieldType(): ?string
  216.     {
  217.         return $this->fieldType;
  218.     }
  219.     /**
  220.      * @param int|null $fieldType
  221.      */
  222.     public function setFieldType(?int $fieldType): self
  223.     {
  224.         $this->fieldType = $fieldType;
  225.         return $this;
  226.     }
  227.     /**
  228.      * @return string|null
  229.      */
  230.     public function getSecondLevel(): ?string
  231.     {
  232.         return $this->secondLevel;
  233.     }
  234.     /**
  235.      * @param string|null $secondLevel
  236.      */
  237.     public function setSecondLevel(?string $secondLevel): self
  238.     {
  239.         $this->secondLevel = $secondLevel;
  240.         return $this;
  241.     }
  242.     /**
  243.      * @return string|null
  244.      */
  245.     public function getThirdLevel(): ?string
  246.     {
  247.         return $this->thirdLevel;
  248.     }
  249.     /**
  250.      * @param string|null $thirdLevel
  251.      */
  252.     public function setThirdLevel(?string $thirdLevel): self
  253.     {
  254.         $this->thirdLevel = $thirdLevel;
  255.         return $this;
  256.     }
  257.     /**
  258.      * @return string|null
  259.      */
  260.     public function getOfferItemNamePL(): ?string
  261.     {
  262.         return $this->offerItemNamePL;
  263.     }
  264.     /**
  265.      * @param string|null $offerItemNamePL
  266.      */
  267.     public function setOfferItemNamePL(?string $offerItemNamePL): self
  268.     {
  269.         $this->offerItemNamePL = $offerItemNamePL;
  270.         return $this;
  271.     }
  272.     /**
  273.      * @return string|null
  274.      */
  275.     public function getOfferItemNameEN(): ?string
  276.     {
  277.         return $this->offerItemNameEN;
  278.     }
  279.     /**
  280.      * @param string|null $offerItemNameEN
  281.      */
  282.     public function setOfferItemNameEN(?string $offerItemNameEN): self
  283.     {
  284.         $this->offerItemNameEN = $offerItemNameEN;
  285.         return $this;
  286.     }
  287.     /**
  288.      * @return bool|null
  289.      */
  290.     public function getIsNameOffer(): ?bool
  291.     {
  292.         return $this->isNameOffer;
  293.     }
  294.     /**
  295.      * @param bool|null $isNameOffer
  296.      */
  297.     public function setIsNameOffer(?bool $isNameOffer): self
  298.     {
  299.         $this->isNameOffer = $isNameOffer;
  300.         return $this;
  301.     }
  302.     /**
  303.      * @return bool|null
  304.      */
  305.     public function getIsLevelOffer(): ?bool
  306.     {
  307.         return $this->isLevelOffer;
  308.     }
  309.     /**
  310.      * @param bool|null $isLevelOffer
  311.      */
  312.     public function setIsLevelOffer(?bool $isLevelOffer): self
  313.     {
  314.         $this->isLevelOffer = $isLevelOffer;
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return string|null
  319.      */
  320.     public function getFieldTypeView(): ?string
  321.     {
  322.         return $this->fieldTypeView;
  323.     }
  324.     /**
  325.      * @param string|null $fieldTypeView
  326.      */
  327.     public function setFieldTypeView(?string $fieldTypeView): self
  328.     {
  329.         $this->fieldTypeView = $fieldTypeView;
  330.         return $this;
  331.     }
  332.     public function getShowLabel()
  333.     {
  334.         return $this->showLabel;
  335.     }
  336.     public function setShowLabel($showLabel): self
  337.     {
  338.         $this->showLabel = $showLabel;
  339.         return $this;
  340.     }
  341. }