src/Entity/Dish.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Traits\Activeable;
  4. use App\Traits\Creatable;
  5. use App\Traits\Deleteable;
  6. use App\Traits\Updateable;
  7. use DateTime;
  8. use DateTimeInterface;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. /**
  14.  * @ORM\Entity(repositoryClass="App\Repository\ComponentRepository")
  15.  * @ORM\Table(name="`dish`")
  16.  * @Gedmo\SoftDeleteable(fieldName="deletedAt")
  17.  */
  18. class Dish
  19. {
  20.     use CreatableUpdateableActiveableDeleteable;
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\Column(type="integer")
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      */
  26.     private ?int $id null;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity="App\Entity\DishTranslation", mappedBy="dish", cascade={"remove", "persist"})
  29.      */
  30.     private Collection $dishTranslations;
  31.     /**
  32.      * @var ?int
  33.      *
  34.      * @ORM\Column(type="integer", nullable=true)
  35.      */
  36.     private ?int $sellingPriceTtc null;
  37.     /**
  38.      * @var ?int
  39.      *
  40.      * @ORM\Column(type="integer", nullable=true)
  41.      */
  42.     private ?int $reducedPrice null;
  43.     /**
  44.      * @var ?DateTime
  45.      *
  46.      * @ORM\Column(type="datetime", nullable=true)
  47.      */
  48.     private ?DateTime $reducedPriceStart null;
  49.     /**
  50.      * @var ?DateTime
  51.      *
  52.      * @ORM\Column(type="datetime", nullable=true)
  53.      */
  54.     private ?DateTime $reducedPriceEnd null;
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity="App\Entity\Document", cascade={"persist"})
  57.      */
  58.     private ?Document $image null;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity="App\Entity\DishCategory", inversedBy="dishes")
  61.      */
  62.     private ?DishCategory $dishCategory null;
  63.     /**
  64.      * @ORM\ManyToMany(targetEntity="App\Entity\Allergen", inversedBy="dishes")
  65.      * @ORM\JoinTable(name="dishes_allergens")
  66.      */
  67.     private Collection $allergens;
  68.     /**
  69.     * @ORM\ManyToMany(targetEntity="App\Entity\Label", inversedBy="dishes")
  70.     * @ORM\OrderBy({"position" = "ASC"})
  71.     */
  72.     private Collection $labels;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity="App\Entity\WinePairing", mappedBy="dish", cascade={"persist", "remove"})
  75.      */
  76.     private Collection $winePairings;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity="App\Entity\BeerPairing", mappedBy="dish", cascade={"persist", "remove"})
  79.      */
  80.     private Collection $beerPairings;
  81.     /**
  82.      * @ORM\ManyToOne(targetEntity="App\Entity\Institution", inversedBy="dishes")
  83.      */
  84.     private ?Institution $institution null;
  85.     /**
  86.      * @var ?int
  87.      *
  88.      * @ORM\Column(name="position", type="integer", nullable=true)
  89.      */
  90.     private ?int $position null;
  91.     /**
  92.      * @var ?bool
  93.      *
  94.      * @ORM\Column(name="highlight", type="boolean", nullable=true)
  95.      */
  96.     private ?bool $highlight null;
  97.     public function __construct()
  98.     {
  99.         $this->allergens = new ArrayCollection();
  100.         $this->labels = new ArrayCollection();
  101.         $this->winePairings = new ArrayCollection();
  102.         $this->beerPairings = new ArrayCollection();
  103.         $this->dishTranslations = new ArrayCollection();
  104.     }
  105.     public function getId(): ?int
  106.     {
  107.         return $this->id;
  108.     }
  109.     /**
  110.      * @return Collection|DishTranslation[]
  111.      */
  112.     public function getDishTranslations(): Collection|array
  113.     {
  114.         return $this->dishTranslations;
  115.     }
  116.     public function addDishTranslation(DishTranslation $dishTranslation): self
  117.     {
  118.         if (!$this->dishTranslations->contains($dishTranslation)) {
  119.             $this->dishTranslations[] = $dishTranslation;
  120.             $dishTranslation->setDish($this);
  121.         }
  122.         return $this;
  123.     }
  124.     public function removeDishTranslation(DishTranslation $dishTranslation): self
  125.     {
  126.         if ($this->dishTranslations->removeElement($dishTranslation)) {
  127.             // set the owning side to null (unless already changed)
  128.             if ($dishTranslation->getDish() === $this) {
  129.                 $dishTranslation->setDish(null);
  130.             }
  131.         }
  132.         return $this;
  133.     }
  134.     public function getSellingPriceTtc(): ?int
  135.     {
  136.         return $this->sellingPriceTtc;
  137.     }
  138.     public function setSellingPriceTtc(?int $sellingPriceTtc): self
  139.     {
  140.         $this->sellingPriceTtc $sellingPriceTtc;
  141.         return $this;
  142.     }
  143.     public function getReducedPrice(): ?int
  144.     {
  145.         return $this->reducedPrice;
  146.     }
  147.     public function setReducedPrice(?int $reducedPrice): self
  148.     {
  149.         $this->reducedPrice $reducedPrice;
  150.         return $this;
  151.     }
  152.     public function getReducedPriceStart(): ?DateTimeInterface
  153.     {
  154.         return $this->reducedPriceStart;
  155.     }
  156.     public function setReducedPriceStart(?DateTimeInterface $reducedPriceStart): self
  157.     {
  158.         $this->reducedPriceStart $reducedPriceStart;
  159.         return $this;
  160.     }
  161.     public function getReducedPriceEnd(): ?DateTimeInterface
  162.     {
  163.         return $this->reducedPriceEnd;
  164.     }
  165.     public function setReducedPriceEnd(?DateTimeInterface $reducedPriceEnd): self
  166.     {
  167.         $this->reducedPriceEnd $reducedPriceEnd;
  168.         return $this;
  169.     }
  170.     public function getImage(): ?Document
  171.     {
  172.         return $this->image;
  173.     }
  174.     public function setImage(?Document $image): self
  175.     {
  176.         $this->image $image;
  177.         return $this;
  178.     }
  179.     public function getDishCategory(): ?DishCategory
  180.     {
  181.         return $this->dishCategory;
  182.     }
  183.     public function setDishCategory(?DishCategory $dishCategory): self
  184.     {
  185.         $this->dishCategory $dishCategory;
  186.         return $this;
  187.     }
  188.     /**
  189.      * @return Collection|Allergen[]
  190.      */
  191.     public function getAllergens(): Collection|array
  192.     {
  193.         return $this->allergens;
  194.     }
  195.     public function addAllergen(Allergen $allergen): self
  196.     {
  197.         if (!$this->allergens->contains($allergen)) {
  198.             $this->allergens[] = $allergen;
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeAllergen(Allergen $allergen): self
  203.     {
  204.         if ($this->allergens->contains($allergen)) {
  205.             $this->allergens->removeElement($allergen);
  206.         }
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection|Label[]
  211.      */
  212.     public function getLabels(): Collection|array
  213.     {
  214.         return $this->labels;
  215.     }
  216.     public function addLabel(Label $label): self
  217.     {
  218.         if (!$this->labels->contains($label)) {
  219.             $this->labels[] = $label;
  220.         }
  221.         return $this;
  222.     }
  223.     public function removeLabel(Label $label): self
  224.     {
  225.         if ($this->labels->contains($label)) {
  226.             $this->labels->removeElement($label);
  227.         }
  228.         return $this;
  229.     }
  230.     /**
  231.      * @return Collection|WinePairing[]
  232.      */
  233.     public function getWinePairings(): array|Collection
  234.     {
  235.         return $this->winePairings;
  236.     }
  237.     public function addWinePairing(WinePairing $winePairing): self
  238.     {
  239.         if (!$this->winePairings->contains($winePairing)) {
  240.             $this->winePairings[] = $winePairing;
  241.             $winePairing->setDish($this);
  242.         }
  243.         return $this;
  244.     }
  245.     public function removeWinePairing(WinePairing $winePairing): self
  246.     {
  247.         if ($this->winePairings->contains($winePairing)) {
  248.             $this->winePairings->removeElement($winePairing);
  249.             // set the owning side to null (unless already changed)
  250.             if ($winePairing->getDish() === $this) {
  251.                 $winePairing->setDish(null);
  252.             }
  253.         }
  254.         return $this;
  255.     }
  256.     /**
  257.      * @return Collection|BeerPairing[]
  258.      */
  259.     public function getBeerPairings(): array|Collection
  260.     {
  261.         return $this->beerPairings;
  262.     }
  263.     public function addBeerPairing(BeerPairing $beerPairing): self
  264.     {
  265.         if (!$this->beerPairings->contains($beerPairing)) {
  266.             $this->beerPairings[] = $beerPairing;
  267.             $beerPairing->setDish($this);
  268.         }
  269.         return $this;
  270.     }
  271.     public function removeBeerPairing(BeerPairing $beerPairing): self
  272.     {
  273.         if ($this->beerPairings->contains($beerPairing)) {
  274.             $this->beerPairings->removeElement($beerPairing);
  275.             // set the owning side to null (unless already changed)
  276.             if ($beerPairing->getDish() === $this) {
  277.                 $beerPairing->setDish(null);
  278.             }
  279.         }
  280.         return $this;
  281.     }
  282.     public function getInstitution(): ?Institution
  283.     {
  284.         return $this->institution;
  285.     }
  286.     public function setInstitution(?Institution $institution): self
  287.     {
  288.         $this->institution $institution;
  289.         return $this;
  290.     }
  291.     public function getPosition(): ?int
  292.     {
  293.         return $this->position;
  294.     }
  295.     public function setPosition(?int $position): self
  296.     {
  297.         $this->position $position;
  298.         return $this;
  299.     }
  300.     public function getHighlight(): ?bool
  301.     {
  302.         return $this->highlight;
  303.     }
  304.     public function setHighlight(?bool $highlight): self
  305.     {
  306.         $this->highlight $highlight;
  307.         return $this;
  308.     }
  309. }