src/Entity/Recipe.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RecipeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassRecipeRepository::class)]
  8. class Recipe
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $name null;
  16.     #[ORM\ManyToMany(targetEntityProduct::class, inversedBy'recipe')]
  17.     private Collection $products;
  18.     #[ORM\ManyToMany(targetEntitySession::class, mappedBy'recipes')]
  19.     private Collection $sessions;
  20.     public function __construct()
  21.     {
  22.         $this->products = new ArrayCollection();
  23.         $this->sessions = new ArrayCollection();
  24.     }
  25.     public function getId(): ?int
  26.     {
  27.         return $this->id;
  28.     }
  29.     public function getName(): ?string
  30.     {
  31.         return $this->name;
  32.     }
  33.     public function setName(string $name): self
  34.     {
  35.         $this->name $name;
  36.         return $this;
  37.     }
  38.     /**
  39.      * @return Collection<int, Product>
  40.      */
  41.     public function getProducts(): Collection
  42.     {
  43.         return $this->products;
  44.     }
  45.     public function addProduct(Product $product): self
  46.     {
  47.         if (!$this->products->contains($product)) {
  48.             $this->products->add($product);
  49.             $product->addRecipe($this);
  50.         }
  51.         return $this;
  52.     }
  53.     public function removeProduct(Product $product): self
  54.     {
  55.         if ($this->products->removeElement($product)) {
  56.             $product->removeRecipe($this);
  57.         }
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, Session>
  62.      */
  63.     public function getSessions(): Collection
  64.     {
  65.         return $this->sessions;
  66.     }
  67.     public function addSession(Session $session): self
  68.     {
  69.         if (!$this->sessions->contains($session)) {
  70.             $this->sessions->add($session);
  71.             $session->addRecipe($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeSession(Session $session): self
  76.     {
  77.         if ($this->sessions->removeElement($session)) {
  78.             $session->removeRecipe($this);
  79.         }
  80.         return $this;
  81.     }
  82. }