src/Entity/ProductOption.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  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\ProductOptionRepository")
  8.  */
  9. class ProductOption
  10. {
  11.     
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="bigint")
  16.      */
  17.     private $id;
  18.     
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $title;
  23.     /**
  24.      * @ORM\Column(type="text")
  25.      */
  26.     private $description;
  27.     
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity="App\Entity\Product", inversedBy="productOptions")
  30.      * @ORM\JoinColumn(name="product_id", referencedColumnName="id", onDelete="SET NULL")
  31.      */
  32.     private $product;
  33.     
  34.     /**
  35.      * @ORM\OneToMany(targetEntity="App\Entity\ProductOptionValue", mappedBy="productOption", orphanRemoval=true, cascade={"persist", "remove"}, fetch="EAGER")
  36.      */
  37.     private $productOptionValues;
  38.     
  39.     /**
  40.      * @ORM\Column(type="boolean")
  41.      */
  42.     private $required;
  43.     /**
  44.      * @ORM\Column(type="boolean")
  45.      */
  46.     private $allow_multiple;
  47.     
  48.     public function __construct ()
  49.     {
  50.         $this->title "";
  51.         $this->description "";
  52.         $this->required false;
  53.         $this->allow_multiple false;
  54.         $this->productOptionValues = new ArrayCollection();
  55.     }
  56.     public function getId()
  57.     {
  58.         return $this->id;
  59.     }
  60.     
  61.     public function getTitle(): ?string
  62.     {
  63.         return $this->title;
  64.     }
  65.     public function setTitle(string $title null): self
  66.     {
  67.         $this->title $title $title "";
  68.         return $this;
  69.     }
  70.     public function getDescription(): ?string
  71.     {
  72.         return $this->description;
  73.     }
  74.     public function setDescription(string $description null): self
  75.     {
  76.         $this->description $description $description "";
  77.         return $this;
  78.     }
  79.     
  80.     public function getProduct(): ?Product
  81.     {
  82.         return $this->product;
  83.     }
  84.     
  85.     public function setProduct(?Product $product null): self
  86.     {
  87.         $this->product $product;
  88.         
  89.         return $this;
  90.     }
  91.     
  92.     /**
  93.      * @return Collection|ProductOptionValue[]
  94.      */
  95.     public function getProductOptionValues(): Collection
  96.     {
  97.         return $this->productOptionValues;
  98.     }
  99.     public function addProductOptionValue(ProductOptionValue $productOptionValue): self
  100.     {
  101.         if (!$this->productOptionValues->contains($productOptionValue)) {
  102.             $this->productOptionValues[] = $productOptionValue;
  103.             $productOptionValue->setProductOption($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeProductOptionValue(ProductOptionValue $productOptionValue): self
  108.     {
  109.         if ($this->productOptionValues->contains($productOptionValue)) {
  110.             $this->productOptionValues->removeElement($productOptionValue);
  111.             // set the owning side to null (unless already changed)
  112.             if ($productOptionValue->getProductOption() === $this) {
  113.                 $productOptionValue->setProductOption(null);
  114.             }
  115.         }
  116.         
  117.         return $this;
  118.     }
  119.     
  120.     public function getRequired(): ?bool
  121.     {
  122.         return $this->required == 1;
  123.     }
  124.     
  125.     public function setRequired(bool $required): self
  126.     {
  127.         $this->required $required 0;
  128.         return $this;
  129.     }
  130.     
  131.     public function getAllowMultiple(): ?bool
  132.     {
  133.         return $this->allow_multiple == 1;
  134.     }
  135.     
  136.     public function setAllowMultiple(bool $allow_multiple): self
  137.     {
  138.         $this->allow_multiple $allow_multiple 0;
  139.         return $this;
  140.     }
  141.     
  142.     public function __toString ()
  143.     {
  144.         return $this->title $this->title '';
  145.     }
  146.     
  147. }