src/Entity/Pack.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PackRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=PackRepository::class)
  9.  */
  10. class Pack
  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 $name;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=Product::class, mappedBy="pack")
  24.      */
  25.     private $products;
  26.     /**
  27.      * @ORM\Column(type="float")
  28.      */
  29.     private $price;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $image;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      */
  37.     private $slug;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=CommandPack::class, mappedBy="pack")
  40.      */
  41.     private $commandPacks;
  42.     /**
  43.      * @ORM\Column(type="string", length=255)
  44.      */
  45.     private $category;
  46.     /**
  47.      * @ORM\Column(type="boolean")
  48.      */
  49.     private $isActivate;
  50.     /**
  51.      * @ORM\OneToMany(targetEntity=ProductPercent::class, mappedBy="pack", cascade={"persist"})
  52.      */
  53.     private $productPercents;
  54.     public function __construct()
  55.     {
  56.         $this->products = new ArrayCollection();
  57.         $this->commandPacks = new ArrayCollection();
  58.         $this->isActivate true;
  59.         $this->productPercents = new ArrayCollection();
  60.     }
  61.     public function getId(): ?int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getName(): ?string
  66.     {
  67.         return $this->name;
  68.     }
  69.     public function setName(?string $name): self
  70.     {
  71.         $this->name $name;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return Collection|Product[]
  76.      */
  77.     public function getProducts(): Collection
  78.     {
  79.         return $this->products;
  80.     }
  81.     public function addProduct(Product $product): self
  82.     {
  83.         if (!$this->products->contains($product)) {
  84.             $this->products[] = $product;
  85.             $product->setPack($this);
  86.         }
  87.         return $this;
  88.     }
  89.     public function removeProduct(Product $product): self
  90.     {
  91.         if ($this->products->contains($product)) {
  92.             $this->products->removeElement($product);
  93.             // set the owning side to null (unless already changed)
  94.             if ($product->getPack() === $this) {
  95.                 $product->setPack(null);
  96.             }
  97.         }
  98.         return $this;
  99.     }
  100.     public function getPrice(): ?float
  101.     {
  102.         return $this->price;
  103.     }
  104.     public function setPrice(float $price): self
  105.     {
  106.         $this->price $price;
  107.         return $this;
  108.     }
  109.     public function getImage()
  110.     {
  111.         return $this->image;
  112.     }
  113.     public function setImage($image): self
  114.     {
  115.         $this->image $image;
  116.         return $this;
  117.     }
  118.     public function getSlug(): ?string
  119.     {
  120.         return $this->slug;
  121.     }
  122.     public function setSlug(string $slug): self
  123.     {
  124.         $this->slug $slug;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Collection|CommandPack[]
  129.      */
  130.     public function getCommandPacks(): Collection
  131.     {
  132.         return $this->commandPacks;
  133.     }
  134.     public function addCommandPack(CommandPack $commandPack): self
  135.     {
  136.         if (!$this->commandPacks->contains($commandPack)) {
  137.             $this->commandPacks[] = $commandPack;
  138.             $commandPack->setPack($this);
  139.         }
  140.         return $this;
  141.     }
  142.     public function removeCommandPack(CommandPack $commandPack): self
  143.     {
  144.         if ($this->commandPacks->contains($commandPack)) {
  145.             $this->commandPacks->removeElement($commandPack);
  146.             // set the owning side to null (unless already changed)
  147.             if ($commandPack->getPack() === $this) {
  148.                 $commandPack->setPack(null);
  149.             }
  150.         }
  151.         return $this;
  152.     }
  153.     public function getCategory(): ?string
  154.     {
  155.         return $this->category;
  156.     }
  157.     public function setCategory(string $category): self
  158.     {
  159.         $this->category $category;
  160.         return $this;
  161.     }
  162.     public function getIsActivate(): ?bool
  163.     {
  164.         return $this->isActivate;
  165.     }
  166.     public function setIsActivate(bool $isActivate): self
  167.     {
  168.         $this->isActivate $isActivate;
  169.         return $this;
  170.     }
  171.     /**
  172.      * @return Collection|ProductPercent[]
  173.      */
  174.     public function getProductPercents(): Collection
  175.     {
  176.         return $this->productPercents;
  177.     }
  178.     public function addProductPercent(ProductPercent $productPercent): self
  179.     {
  180.         if (!$this->productPercents->contains($productPercent)) {
  181.             $this->productPercents[] = $productPercent;
  182.             $productPercent->setPack($this);
  183.         }
  184.         return $this;
  185.     }
  186.     public function removeProductPercent(ProductPercent $productPercent): self
  187.     {
  188.         if ($this->productPercents->contains($productPercent)) {
  189.             $this->productPercents->removeElement($productPercent);
  190.             // set the owning side to null (unless already changed)
  191.             if ($productPercent->getPack() === $this) {
  192.                 $productPercent->setPack(null);
  193.             }
  194.         }
  195.         return $this;
  196.     }
  197. }