src/Entity/DiscountModel.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DiscountModelRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassDiscountModelRepository::class)]
  8. class DiscountModel
  9. {
  10.     //TODO: rajouter le lien à une section
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[ORM\Column(type'string'length100)]
  16.     private $name;
  17.     #[ORM\Column(type'smallint')]
  18.     private $amount;
  19.     #[ORM\Column(type'boolean')]
  20.     private $isDisplayed;
  21.     #[ORM\OneToMany(mappedBy'model'targetEntityDiscount::class)]
  22.     private $discounts;
  23.     #[ORM\OneToMany(mappedBy'discountModel'targetEntityDocumentModel::class)]
  24.     private $documentModels;
  25.     #[ORM\Column(type'smallint'nullabletrue)]
  26.     private $ageMin;
  27.     #[ORM\Column(type'smallint'nullabletrue)]
  28.     private $ageMax;
  29.     #[ORM\Column(type'text')]
  30.     private $label;
  31.     public function __construct()
  32.     {
  33.         $this->discounts = new ArrayCollection();
  34.         $this->documentModels = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getName(): ?string
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function setName(string $name): self
  45.     {
  46.         $this->name $name;
  47.         return $this;
  48.     }
  49.     public function getAmount(): ?int
  50.     {
  51.         return $this->amount;
  52.     }
  53.     public function setAmount(int $amount): self
  54.     {
  55.         $this->amount $amount;
  56.         return $this;
  57.     }
  58.     public function getIsDisplayed(): ?bool
  59.     {
  60.         return $this->isDisplayed;
  61.     }
  62.     public function setIsDisplayed(bool $isDisplayed): self
  63.     {
  64.         $this->isDisplayed $isDisplayed;
  65.         return $this;
  66.     }
  67.     /**
  68.      * @return Collection<int, Discount>
  69.      */
  70.     public function getDiscounts(): Collection
  71.     {
  72.         return $this->discounts;
  73.     }
  74.     public function addDiscount(Discount $discount): self
  75.     {
  76.         if (!$this->discounts->contains($discount)) {
  77.             $this->discounts[] = $discount;
  78.             $discount->setModel($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removeDiscount(Discount $discount): self
  83.     {
  84.         if ($this->discounts->removeElement($discount)) {
  85.             // set the owning side to null (unless already changed)
  86.             if ($discount->getModel() === $this) {
  87.                 $discount->setModel(null);
  88.             }
  89.         }
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection<int, DocumentModel>
  94.      */
  95.     public function getDocumentModels(): Collection
  96.     {
  97.         return $this->documentModels;
  98.     }
  99.     public function addDocumentModel(DocumentModel $documentModel): self
  100.     {
  101.         if (!$this->documentModels->contains($documentModel)) {
  102.             $this->documentModels[] = $documentModel;
  103.             $documentModel->setDiscountModel($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeDocumentModel(DocumentModel $documentModel): self
  108.     {
  109.         if ($this->documentModels->removeElement($documentModel)) {
  110.             // set the owning side to null (unless already changed)
  111.             if ($documentModel->getDiscountModel() === $this) {
  112.                 $documentModel->setDiscountModel(null);
  113.             }
  114.         }
  115.         return $this;
  116.     }
  117.     public function getAgeMin(): ?int
  118.     {
  119.         return $this->ageMin;
  120.     }
  121.     public function setAgeMin(?int $ageMin): self
  122.     {
  123.         $this->ageMin $ageMin;
  124.         return $this;
  125.     }
  126.     public function getAgeMax(): ?int
  127.     {
  128.         return $this->ageMax;
  129.     }
  130.     public function setAgeMax(?int $ageMax): self
  131.     {
  132.         $this->ageMax $ageMax;
  133.         return $this;
  134.     }
  135.     public function createDiscount(): Discount
  136.     {
  137.         $discount = new Discount();
  138.         $this->addDiscount($discount);
  139.         return $discount;
  140.     }
  141.     public function getLabel(): ?string
  142.     {
  143.         return $this->label;
  144.     }
  145.     public function setLabel(string $label): self
  146.     {
  147.         $this->label $label;
  148.         return $this;
  149.     }
  150. }