<?php
namespace App\Entity;
use App\Repository\ProductRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProductRepository::class)]
class Product
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(nullable: true)]
private ?float $price = null;
#[ORM\ManyToOne(inversedBy: 'products')]
private ?StoreArea $storeArea = null;
#[ORM\ManyToMany(targetEntity: Recipe::class, mappedBy: 'products')]
private Collection $recipe;
public function __construct()
{
$this->recipe = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(?float $price): self
{
$this->price = $price;
return $this;
}
public function getStoreArea(): ?StoreArea
{
return $this->storeArea;
}
public function setStoreArea(?StoreArea $storeArea): self
{
$this->storeArea = $storeArea;
return $this;
}
/**
* @return Collection<int, Recipe>
*/
public function getRecipe(): Collection
{
return $this->recipe;
}
public function addRecipe(Recipe $recipe): self
{
if (!$this->recipe->contains($recipe)) {
$this->recipe->add($recipe);
}
return $this;
}
public function removeRecipe(Recipe $recipe): self
{
$this->recipe->removeElement($recipe);
return $this;
}
}