src/Entity/DiscountName.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DiscountNameRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=DiscountNameRepository::class)
  9.  */
  10. class DiscountName
  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)
  20.      */
  21.     private $content;
  22.     public function getId(): ?int
  23.     {
  24.         return $this->id;
  25.     }
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Discount::class, mappedBy="discountName")
  28.      */
  29.     private $discounts;
  30.     public function __construct()
  31.     {
  32.         $this->discounts = new ArrayCollection();
  33.     }
  34.     public function getContent(): ?string
  35.     {
  36.         return $this->content;
  37.     }
  38.     public function setContent(string $content): self
  39.     {
  40.         $this->content $content;
  41.         return $this;
  42.     }
  43.     public function __toString()
  44.     {
  45.         return $this->content;
  46.     }
  47.     /**
  48.      * @return Collection<int, Discount>
  49.      */
  50.     public function getDiscounts(): Collection
  51.     {
  52.         return $this->discounts;
  53.     }
  54.     public function addDiscount(Discount $discount): self
  55.     {
  56.         if (!$this->discounts->contains($discount)) {
  57.             $this->discounts[] = $discount;
  58.             $discount->setDiscountName($this);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeDiscount(Discount $discount): self
  63.     {
  64.         if ($this->discounts->removeElement($discount)) {
  65.             // set the owning side to null (unless already changed)
  66.             if ($discount->getDiscountName() === $this) {
  67.                 $discount->setDiscountName(null);
  68.             }
  69.         }
  70.         return $this;
  71.     }
  72. }