src/Entity/Product.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassProductRepository::class)]
  8. class Product
  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\Column(nullabletrue)]
  17.     private ?float $price null;
  18.     #[ORM\ManyToOne(inversedBy'products')]
  19.     private ?StoreArea $storeArea null;
  20.     #[ORM\ManyToMany(targetEntityRecipe::class, mappedBy'products')]
  21.     private Collection $recipe;
  22.     public function __construct()
  23.     {
  24.         $this->recipe = new ArrayCollection();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getName(): ?string
  31.     {
  32.         return $this->name;
  33.     }
  34.     public function setName(string $name): self
  35.     {
  36.         $this->name $name;
  37.         return $this;
  38.     }
  39.     public function getPrice(): ?float
  40.     {
  41.         return $this->price;
  42.     }
  43.     public function setPrice(?float $price): self
  44.     {
  45.         $this->price $price;
  46.         return $this;
  47.     }
  48.     public function getStoreArea(): ?StoreArea
  49.     {
  50.         return $this->storeArea;
  51.     }
  52.     public function setStoreArea(?StoreArea $storeArea): self
  53.     {
  54.         $this->storeArea $storeArea;
  55.         return $this;
  56.     }
  57.     /**
  58.      * @return Collection<int, Recipe>
  59.      */
  60.     public function getRecipe(): Collection
  61.     {
  62.         return $this->recipe;
  63.     }
  64.     public function addRecipe(Recipe $recipe): self
  65.     {
  66.         if (!$this->recipe->contains($recipe)) {
  67.             $this->recipe->add($recipe);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeRecipe(Recipe $recipe): self
  72.     {
  73.         $this->recipe->removeElement($recipe);
  74.         return $this;
  75.     }
  76. }