src/Admin/Modules/OfferGenerator/Entity/OfferGeneratorPriceListGroup.php line 13

  1. <?php
  2. namespace App\Admin\Modules\OfferGenerator\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Table(name="offer_generator_price_list_group")
  8.  * @ORM\Entity
  9.  */
  10. class OfferGeneratorPriceListGroup
  11. {
  12.     /**
  13.      * @ORM\Column(type="integer")
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue(strategy="AUTO")
  16.      */
  17.     private $id;
  18.     
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity="App\Admin\Modules\OfferGenerator\Entity\OfferGeneratorPriceList", inversedBy="groups")
  21.      * @ORM\JoinColumns({
  22.      *   @ORM\JoinColumn(name="id_offer_generator_price_list", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  23.      * })
  24.      */
  25.     private $priceList;
  26.     /**
  27.      * @ORM\Column(name="name", type="string", length=255, nullable=false)
  28.      */
  29.     private $name;   
  30.     
  31.     /**
  32.      * @ORM\OneToMany(targetEntity="App\Admin\Modules\OfferGenerator\Entity\OfferGeneratorPriceListGroupItem", mappedBy="group", cascade={"persist"}, orphanRemoval=true)
  33.      * @ORM\OrderBy({"id"="ASC"})
  34.      **/
  35.     private $items;
  36.     public function __construct()
  37.     {
  38.         $this->items = new ArrayCollection();
  39.     }
  40.     public function __toString()
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(string $name): self
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     public function getPriceList(): ?OfferGeneratorPriceList
  58.     {
  59.         return $this->priceList;
  60.     }
  61.     public function setPriceList(?OfferGeneratorPriceList $priceList): self
  62.     {
  63.         $this->priceList $priceList;
  64.         return $this;
  65.     }
  66.     /**
  67.      * @return Collection<int, OfferGeneratorPriceListGroupItem>
  68.      */
  69.     public function getItems(): Collection
  70.     {
  71.         return $this->items;
  72.     }
  73.     public function addItem(OfferGeneratorPriceListGroupItem $item): self
  74.     {
  75.         if (!$this->items->contains($item)) {
  76.             $this->items->add($item);
  77.             $item->setGroup($this);
  78.         }
  79.         return $this;
  80.     }
  81.     public function removeItem(OfferGeneratorPriceListGroupItem $item): self
  82.     {
  83.         if ($this->items->removeElement($item)) {
  84.             // set the owning side to null (unless already changed)
  85.             if ($item->getGroup() === $this) {
  86.                 $item->setGroup(null);
  87.             }
  88.         }
  89.         return $this;
  90.     }
  91. }