src/Entity/Item/ItemCategory.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Item;
  3. use App\Entity\Blog;
  4. use App\Entity\Package\Package;
  5. use App\Entity\Search\SearchIndustry;
  6. use App\Entity\SeoIndustry;
  7. use App\Entity\Traits\IdTrait;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12.  * @ORM\Entity(repositoryClass=ItemCategoryRepository::class)
  13.  */
  14. class ItemCategory
  15. {
  16.     use IdTrait;
  17.     /**
  18.      * @ORM\Column(type="datetime")
  19.      */
  20.     private $createdAt;
  21.     /**
  22.      * @ORM\Column(type="datetime")
  23.      */
  24.     private $updatedAt;
  25.     /**
  26.      * @ORM\Column(type="string", length=255,nullable=true)
  27.      */
  28.     private $name;
  29.      /**
  30.      * @ORM\Column(type="string", length=255,nullable=true)
  31.      */
  32.     private $info;
  33.     /**
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     private $fieldType;
  37.     /**
  38.      * @ORM\Column(type="boolean",nullable=true)
  39.      */
  40.     private $canBeNiceToHave;
  41.     /**
  42.      * @ORM\ManyToMany(targetEntity=Item::class, mappedBy="itemCategories",cascade={"persist","remove","refresh"})
  43.      * @ORM\JoinColumn(nullable=true)
  44.      */
  45.     private $items;
  46.     /**
  47.      * @ORM\Column(type="string", length=255,nullable=true)
  48.      */
  49.     private $categoryType;
  50.     /**
  51.      * @ORM\Column(type="boolean",nullable=true)
  52.      */
  53.     private $required;
  54.     
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity=ItemCategory::class, inversedBy="relatedItemCategories",cascade={"persist","remove"})
  57.      * @ORM\JoinColumn(nullable=true)
  58.      */
  59.     private $itemCategory;
  60.     /**
  61.      * @ORM\OneToMany(targetEntity=ItemCategory::class, mappedBy="itemCategory",cascade={"persist","remove"},orphanRemoval=true)
  62.      * @ORM\JoinColumn(nullable=true)
  63.      */
  64.     private $relatedItemCategories;
  65.     /**
  66.      * @ORM\Column(type="string",length=255,nullable=true)
  67.      */
  68.     private $placeholder;
  69.     /**
  70.      * @ORM\Column(type="boolean", nullable=true)
  71.      */
  72.     private $canEnterOwn;
  73.     /**
  74.      * @ORM\Column(type="json", nullable=true)
  75.      */
  76.     private $translation;
  77.     
  78.     /**
  79.      * @ORM\Column(type="boolean", nullable=true)
  80.      */
  81.     private $showCanNiceToBeHaveButton;
  82.     /**
  83.      * @ORM\OneToMany(targetEntity="App\Entity\Blog", mappedBy="industry",cascade={"persist","remove"})
  84.      * @ORM\JoinColumn(nullable=true)
  85.      */
  86.     private $blog;
  87.     
  88.     /**
  89.      * @ORM\Column(type="boolean", nullable=true)
  90.      */
  91.     private $active;
  92.     /**
  93.      * @ORM\Column(type="boolean", nullable=true)
  94.      */
  95.     private $isNameOffer;
  96.     /**
  97.      * @ORM\Column(type="boolean", nullable=true)
  98.      */
  99.     private $isLevelOffer;
  100.     /**
  101.      * @ORM\ManyToOne(targetEntity=SeoIndustry::class, inversedBy="industry", cascade={"persist", "remove"})
  102.      * @ORM\JoinColumn(nullable=true)
  103.      */
  104.     private $seoIndustry;
  105.     /**
  106.      * @ORM\Column(type="string", length=255, nullable=true)
  107.      */
  108.     private ?string $searchSlug;
  109.     /**
  110.      * @ORM\Column(type="string", length=255, nullable=true)
  111.      */
  112.     private ?string $fieldTypeView;
  113.     /**
  114.      * @ORM\OneToMany(targetEntity=SearchIndustry::class, mappedBy="itemCategory", cascade={"persist","remove"})
  115.      */
  116.     private $searchIndustry;
  117.     /**
  118.      * @ORM\Column(type="boolean", nullable=true)
  119.      */
  120.     private $isTechnology;
  121.     /**
  122.      * @ORM\Column(type="integer", nullable=true)
  123.      */
  124.     private $itemQuantity = 10;
  125.     /**
  126.      * @ORM\Column(type="integer", nullable=true)
  127.      */
  128.     private $position;
  129.     /**
  130.      * @ORM\ManyToMany(targetEntity=Package::class, mappedBy="industry")
  131.      */
  132.     private $packages;
  133.     /**
  134.      * @ORM\Column(type="boolean", nullable=true)
  135.      */
  136.     private $showLabel;
  137.     public function __construct()
  138.     {
  139.         $this->items  = new ArrayCollection();
  140.         $this->relatedItemCategories = new ArrayCollection();
  141.         $this->blog = new ArrayCollection();
  142.         $this->searchIndustry = new ArrayCollection();
  143.         $this->packages = new ArrayCollection();
  144.     }
  145.     public function getId(): ?int
  146.     {
  147.         return $this->id;
  148.     }
  149.     public function getCreatedAt(): ?\DateTimeInterface
  150.     {
  151.         return $this->createdAt;
  152.     }
  153.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  154.     {
  155.         $this->createdAt = $createdAt;
  156.         return $this;
  157.     }
  158.     public function getUpdatedAt(): ?\DateTimeInterface
  159.     {
  160.         return $this->updatedAt;
  161.     }
  162.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  163.     {
  164.         $this->updatedAt = $updatedAt;
  165.         return $this;
  166.     }
  167.     public function getName(): ?string
  168.     {
  169.         return $this->name;
  170.     }
  171.     public function setName(string $name): self
  172.     {
  173.         $this->name = $name;
  174.         return $this;
  175.     }
  176.     public function getInfo(): ?string
  177.     {
  178.         return $this->info;
  179.     }
  180.     public function setInfo(string $info): self
  181.     {
  182.         $this->info = $info;
  183.         return $this;
  184.     }
  185.     public function getFieldType(): ?string
  186.     {
  187.         return $this->fieldType;
  188.     }
  189.     public function setFieldType(string $fieldType): self
  190.     {
  191.         $this->fieldType = $fieldType;
  192.         return $this;
  193.     }
  194.     public function getCanBeNiceToHave(): ?bool
  195.     {
  196.         return $this->canBeNiceToHave;
  197.     }
  198.     public function setCanBeNiceToHave(bool $canBeNiceToHave): self
  199.     {
  200.         $this->canBeNiceToHave = $canBeNiceToHave;
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return Collection|Item[]
  205.      */
  206.     public function getItems(): Collection
  207.     {
  208.         return $this->items;
  209.     }
  210.     public function addItem(Item $item): self
  211.     {
  212.         if (!$this->items->contains($item)) {
  213.             $this->items[] = $item;
  214.             $item->addItemCategory($this);
  215.         }
  216.         return $this;
  217.     }
  218.     public function removeItem(Item $item): self
  219.     {
  220.         if ($this->items->removeElement($item)) {
  221.             // set the owning side to null (unless already changed)
  222.             if ($item->getItemCategories() === $this) {
  223.                 $item->removeItemCategory(null);
  224.             }
  225.         }
  226.         return $this;
  227.     }
  228.     public function getCategoryType(): ?string
  229.     {
  230.         return $this->categoryType;
  231.     }
  232.     public function setCategoryType(string $categoryType): self
  233.     {
  234.         $this->categoryType = $categoryType;
  235.         return $this;
  236.     }
  237.     public function getRequired(): ?bool
  238.     {
  239.         return $this->required;
  240.     }
  241.     public function setRequired(bool $required): self
  242.     {
  243.         $this->required = $required;
  244.         return $this;
  245.     }
  246.     public function getItemCategory(): ?self
  247.     {
  248.         return $this->itemCategory;
  249.     }
  250.     public function setItemCategory(?self $itemCategory): self
  251.     {
  252.         $this->itemCategory = $itemCategory;
  253.         return $this;
  254.     }
  255.     /**
  256.      * @return Collection|self[]
  257.      */
  258.     public function getRelatedItemCategories(): Collection
  259.     {
  260.         return $this->relatedItemCategories;
  261.     }
  262.     public function addRelatedItemCategory(self $relatedItemCategory): self
  263.     {
  264.         if (!$this->relatedItemCategories->contains($relatedItemCategory)) {
  265.             $this->relatedItemCategories[] = $relatedItemCategory;
  266.             $relatedItemCategory->setItemCategory($this);
  267.         }
  268.         return $this;
  269.     }
  270.     public function removeRelatedItemCategory(self $relatedItemCategory): self
  271.     {
  272.         if ($this->relatedItemCategories->removeElement($relatedItemCategory)) {
  273.             // set the owning side to null (unless already changed)
  274.             if ($relatedItemCategory->getItemCategory() === $this) {
  275.                 $relatedItemCategory->setItemCategory(null);
  276.             }
  277.         }
  278.         return $this;
  279.     }
  280.     public function getPlaceholder(): ?string
  281.     {
  282.         return $this->placeholder;
  283.     }
  284.     public function setPlaceholder(string $placeholder): self
  285.     {
  286.         $this->placeholder = $placeholder;
  287.         return $this;
  288.     }
  289.     public function getCanEnterOwn(): ?bool
  290.     {
  291.         return $this->canEnterOwn;
  292.     }
  293.     public function setCanEnterOwn(bool $canEnterOwn): self
  294.     {
  295.         $this->canEnterOwn = $canEnterOwn;
  296.         return $this;
  297.     }
  298.     public function getTranslation(): ?array
  299.     {
  300.         return $this->translation;
  301.     }
  302.     public function setTranslation(array $translation): self
  303.     {
  304.         $this->translation = $translation;
  305.         return $this;
  306.     }
  307.     public function getShowCanNiceToBeHaveButton(): ?bool
  308.     {
  309.         return $this->showCanNiceToBeHaveButton;
  310.     }
  311.     public function setShowCanNiceToBeHaveButton(bool $showCanNiceToBeHaveButton): self
  312.     {
  313.         $this->showCanNiceToBeHaveButton = $showCanNiceToBeHaveButton;
  314.         return $this;
  315.     }
  316.     public function getItemCategoryById(?int $itemCategoryId): ?ItemCategory
  317.     {
  318.         foreach($this->getRelatedItemCategories()->toArray() as $itemCategory){
  319.             if($itemCategory->getId() === $itemCategoryId){ return $itemCategory; }
  320.         }
  321.         return null;
  322.     }
  323.     public function getItemFromItemCategoryById(int $itemId): ?Item
  324.     {
  325.         foreach($this->getItems()->toArray() as $item){
  326.             if($item->getId() === $itemId){ return $item; }
  327.         }
  328.         return null;
  329.     }
  330.     
  331.      /**
  332.      * @return Collection|Blog[]
  333.      */
  334.     public function getBlog(): Collection
  335.     {
  336.         return $this->blog;
  337.     }
  338.     public function addBlog(Blog $blog):self
  339.     {
  340.         $this->blog[] = $blog;
  341.         return $this;
  342.     }
  343.     public function removeBlog(Blog $blog):self
  344.     {
  345.         if ($this->blog->removeElement($blog)) {
  346.             // set the owning side to null (unless already changed)
  347.             if ($blog->getIndustry() === $this) {
  348.                 $blog->setIndustry(null);
  349.             }
  350.         }
  351.         return $this;
  352.     }
  353.     public function getActive(): ?bool
  354.     {
  355.         return $this->active;
  356.     }
  357.     public function setActive(bool $active): self
  358.     {
  359.         $this->active = $active;
  360.         return $this;
  361.     }
  362.     public function getIsNameOffer(): ?bool
  363.     {
  364.         return $this->isNameOffer;
  365.     }
  366.     public function setIsNameOffer(bool $isNameOffer): self
  367.     {
  368.         $this->isNameOffer = $isNameOffer;
  369.         return $this;
  370.     }
  371.     public function setIsLevelOffer(bool $isLevelOffer): self
  372.     {
  373.         $this->isLevelOffer = $isLevelOffer;
  374.         return $this;
  375.     }
  376.     public function getIsLevelOffer(): ?bool
  377.     {
  378.         return $this->isLevelOffer;
  379.     }
  380.     public function setSeoIndustry(?SeoIndustry $seoIndustry): self
  381.     {
  382.         $this->seoIndustry = $seoIndustry;
  383.         return $this;
  384.     }
  385.     public function getSeoIndustry(): ?SeoIndustry
  386.     {
  387.         return $this->seoIndustry;
  388.     }
  389.     /**
  390.      * @return string|null
  391.      */
  392.     public function getSearchSlug(): ?string
  393.     {
  394.         return $this->searchSlug;
  395.     }
  396.     /**
  397.      * @param string|null $searchSlug
  398.      */
  399.     public function setSearchSlug(?string $searchSlug): self
  400.     {
  401.         $this->searchSlug = $searchSlug;
  402.         return $this;
  403.     }
  404.     /**
  405.      * @return string|null
  406.      */
  407.     public function getFieldTypeView(): ?string
  408.     {
  409.         return $this->fieldTypeView;
  410.     }
  411.     /**
  412.      * @param string|null $fieldTypeView
  413.      */
  414.     public function setFieldTypeView(?string $fieldTypeView): self
  415.     {
  416.         $this->fieldTypeView = $fieldTypeView;
  417.         return $this;
  418.     }
  419.       /**
  420.      * @return Collection|Blog[]
  421.      */
  422.     public function getSearchIndustry(): Collection
  423.     {
  424.         return $this->searchIndustry;
  425.     }
  426.     public function addSearchIndustry(?SearchIndustry $searchIndustry):self
  427.     {
  428.         $this->searchIndustry[] = $searchIndustry;
  429.         return $this;
  430.     }
  431.     public function removeSearchIndustry(?SearchIndustry $searchIndustry):self
  432.     {
  433.         if ($this->searchIndustry->removeElement($searchIndustry)) {
  434.             // set the owning side to null (unless already changed)
  435.             if ($searchIndustry->getItemCategory() === $this) {
  436.                 $searchIndustry->setItemCategory(null);
  437.             }
  438.         }
  439.         return $this;
  440.     }
  441.     public function getIsTechnology(): ?bool
  442.     {
  443.         return $this->isTechnology;
  444.     }
  445.     public function setIsTechnology(?bool $isTechnology): self
  446.     {
  447.         $this->isTechnology = $isTechnology;
  448.         return $this;
  449.     }
  450.     public function getItemQuantity(): ?int
  451.     {
  452.         return $this->itemQuantity;
  453.     }
  454.     public function setItemQuantity(?int $itemQuantity): self
  455.     {
  456.         $this->itemQuantity = $itemQuantity;
  457.         return $this;
  458.     }
  459.     public function getPosition(): ?int
  460.     {
  461.         return $this->position;
  462.     }
  463.     public function setPosition(?int $position): self
  464.     {
  465.         $this->position = $position;
  466.         return $this;
  467.     }
  468.     public function getPackages(): ArrayCollection
  469.     {
  470.         return $this->packages;
  471.     }
  472.     public function addPackage(?Package $package): self
  473.     {
  474.         if (!$this->packages->contains($package)) {
  475.             $this->packages[] = $package;
  476.         }
  477.         return $this;
  478.     }
  479.     public function removePackage(?Package $package): self
  480.     {
  481.         $this->packages->removeElement($package);
  482.         return $this;
  483.     }
  484.     public function getShowLabel()
  485.     {
  486.         return $this->showLabel;
  487.     }
  488.     public function setShowLabel(bool $showLabel): self
  489.     {
  490.         $this->showLabel = $showLabel;
  491.         return $this;
  492.     }
  493. }